Using jQuery, is it possible to set a piece of text <option>for a specific color? For instance:
<option>
<option>John, Rambo, Indiana, Jones, Morpheus, John, McClane, Forrest, Gump</option>
If I want to just change the color of Morpheus. Is it possible?
If you had in mind the value of the option select, there is no simple or even cross-browser solution . You will need to resort to some special solution with LIs, to emulate a custom checkbox, and then you can create it using jquery.
select
LIs
For example, check here for one option that you can customize (add colors, etc.) as you like.
, jquery , - javascript :
"John,Rambo,Indiana,Jones,Morpheus,John,McClane,Forrest,Gump".replace(/Morpheus/gi, "<p style='color:blue'>Morpheus</p>")
( JQuery) , - ...
<SELECT> <OPTION>What is your preferred browser?</OPTION> <OPTION id="b1" style="color:Blue">Explorer 5.5</OPTION> <OPTION id="r1" style="color:Red">Explorer 6.0</OPTION> </SELECT>
Then ... use jQuery to change the CSS color for the "b1" or "r1" element ...
$("#b1").css("color", "#FF0000");
Try the following:
$("#mySelect option:contains('Morpheus')").css("background-color","red")
Source: https://habr.com/ru/post/1788986/More articles:Resizing a frame on Safari / iPhone - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1788982/converting-regular-properties-to-auto-implemented-properties&usg=ALkJrhgX_9jGikF1c9-IFgaN3k6K3ibl8Qregex selection - ruby | fooobar.comПерекрестная ссылка функционального индекса в Oracle - oracleHow to get the height of a hidden image? - javascriptHow do I avoid ampersands in URLs when logging in with OpenID? - google-app-engineSax parsing with a local name of more than one kind - javahttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1788989/how-to-apply-effects-to-camera-images&usg=ALkJrhgCml_vMra09DYJoAe-z57DNLsuFwReserved user data in a database - how to structure? For example, recipes use ingredients - sqlR: Technical analysis results for the year - rAll Articles