How to remove and add a new css class with jQuery? -


here example

<a href="javascript:void(0)" id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_a" title="10" style="text-decoration:none"><span id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_star_1" class="ratingstar emptyratingstar" style="float:left;">&nbsp;</span><span id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_star_2" class="ratingstar filledratingstar" style="float:left;">&nbsp;</span><span id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_star_3" class="ratingstar filledratingstar" style="float:left;">&nbsp;</span><span id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_star_4" class="ratingstar filledratingstar" style="float:left;">&nbsp;</span><span id="ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_star_5" class="ratingstar filledratingstar" style="float:left;">&nbsp;</span> </a> 

so need remove ratingstar filledratingstar class on click child elements of anchor tab , apply different class ratingstar emptyratingstar

you can use .addclass() , .removeclass():

$(document).ready(function(){   $("#ctl00_ctl00_cphcontent_cphinnercontent_viewphotosctrl_ddrating_a").click(function(){     $(this).find("span").removeclass("filledratingstar").addclass("emptyratingstar");   }); }); 

hope helps. cheers


Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -