I am trying to change the image source in the Jquery
<a href="" class="wanted" id="'.$status_id[$num].'"><img src="/images/wanted.png">
through a JQuery selector:
$(".wanted "+ id).attr("src", '/images/wanted_.png');
Where id is defined in the javascript as the php variable $status_id[$num]. I first tried using $(this) to no avail. Any insight would be helpful.
When you access
$(".wanted"+id), you are actually trying to access an element with the class name = wanted+id. This is because of the ‘.’ before ‘wanted’. Also, you seem to be accessing the<a>tag directly and setting it’ssrcattribute. You need to access the<img>tag.What you could try is this: