Hello,
The selector would be simply:
jQuery( '#fieldname6_1' ).css( "background", "red" );
I don’t know why you are assigning the colors with jQuery, and not with CSS rules. However, as I don’t know if your theme is assigning a color to the “SELECT” tags with the modifier “!important”, I recommend you assign the color as follows:
jQuery( 'select' ).attr( 'style', 'color:red !important;' );
Best regards.
Thanks ! All right, i think i was trying css without !important so it was not working.
In fact i was trying to set the selected option of my form ACCORDING TO THE PAGE where the form is shown.
I have found a solution that might be a bit messy but it works. The idea is to simply add a class to each of my post page for example :
.porsche_cayman for porsche cayman post page
.lamborghini_aventador for lamborghini aventador
and then creat all the line and changing the class each time and the eq(number) that refer to vehicle .
jQuery('div.porsche_cayman #fieldname6_1 option').eq(1).prop('selected', true);
jQuery('div.lamborghini_aventador #fieldname6_1 option').eq(1).prop('selected', true);
Do you think there is a solution where i could simply compare the page title with the <option> name attribut so the selected attribut could be set according to the page title?
For example if my form is in the page porsche cayman which i got with echo get_the_title(); , how can add the selected attribut to the right <option> with the name porsche cayman ?
I can’t see any name attribut on the form, only a vt= .
-
This reply was modified 9 years, 4 months ago by
nathalizator.
-
This reply was modified 9 years, 4 months ago by
nathalizator.
-
This reply was modified 9 years, 4 months ago by
nathalizator.