Tag Archives: css

Setting Style/CSS of select options using jQuery

This is how i set style (color here) of all of the options of a select list using jQuery.

In my case i had select options like this:

<select id=”select_list_id”>
<option value=”#595959″>Grey</option>
<option value=”#000000″>Black</option>
<option value=”#036″>Blue</option>
<option value=”#363″>Green</option>
<option value=”#632423″>Red</option>
<option value=”#403152″>Purple</option>
<option value=”#E36C0A”>Orange</option>
</select>

Follwoing the jQuery code i used to set color of options above:

  $(document).ready(function(){
	$('#select_list_id option', this).each(	
		function ()	{
			$(this).css({'color':$(this).val()});
		}
	)
  });

When Firebug made life easier

It’s been around three years now i have been using the Firebug. This great tool provides a web developer an easy way to look at and inspect the source code of a web page. You can view and experiment with each and every part of your web page and related DOM elements, inline or linked CSS, JavaScript and not to say the entire page content. Continue reading