0

Here is my 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 I need to remove ratingStar filledRatingStar class on click from all child elements of anchor tab and apply a different class ratingStar emptyRatingStar

0

3 Answers 3

2

You can use .addClass() and .removeClass():

$(document).ready(function(){
  $("#ctl00_ctl00_cphContent_cphInnerContent_ViewPhotosCtrl_ddRating_A").click(function(){
    $(this).find("span").removeClass("filledRatingStar").addClass("emptyRatingStar");
  });
});

Hope this helps. Cheers

Sign up to request clarification or add additional context in comments.

Comments

1

Try:

$("a").click(function() {
    $(this).children().removeClass("filledRatingStar").addClass("emptyRatingStar");
});

Comments

0
$("a").click(function(){
   $(this).children().removeClass("filledRatingStar").addClass("emptyRatingStar");
});

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.