It is required among the hundreds of tags "a" to find the required class with the selected class and add one more class to it.
if($('a').hasClass('selected')){ $(this).addClass('red'); } .red{color: red;} <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <a href="#" class="selected">One</a> Something is not right ...
thisis equal to. Look at what it is equal in your case - Grundyselectedadd another class. First select the necessary elements, and then add a class to them:$('a.selected').addClass('red')- Grundy