I am attempting to assign a class to an element with a specific ID using jQuery. I've done this before without any problems, but for some reason, it's refusing to work now.
Here is a series of divs (the code is in a loop) from which I want to retrieve a single, unique div:
<div id = "<?php echo $result.'_s'; ?>" > <img src = "http://localhost/gallerySite/users/thumbnails/<?php echo $result; ?>" /> </div>
...and here is the jQuery code I'm doing it with:
$('#batman').addClass('myClass');
When I run the program, the class simply isn't being applied to the div, and when I alert the length of the div, it returns 0, even though I can see it in the page source on Chrome. I've checked for spelling errors, and made sure the JS file is included in the correct place. What's odd though, is that when I assign a static value to the divs, let's say, "class = robin", and in jQuery, assign the 'batman' class to the divs with the 'robin', the program works fine. I suspect it may have something to do with the inline PHP in the HTML file, but I'm not sure why that would be an issue.
Any ideas?
Thanks.