My page makes an ajax call and creates some markup on the page from the results. How do I then add a class to one of these elements. For example:
<div id="hiddenresult">
<div class="page">
<p><a id="23">Some link</a></p>
</div>
</div>
This markup has been inserted by javascript so when I do:
$('#hiddenresult a#23').addClass("myClass");
It does nothing.
I want to be able to add a class to the anchor when I click a link on my page. Something like this:
$('#button').click(function() {
$('#hiddenresult a#23').addClass("myClass");
});
The id of any dom element should always be unique and must not start with a number. You can just try this to add the class.