I am trying to add the onclick function to an image using jQuery and for some reason it does not stick. My code looks like this:
var img = $('<img></ >').attr('id',i+5)
.attr("src","images/16-arrow-right.png")
.addClass("expImg")
.click(function(){expand(this, 'tdb', 'years', 'danwoods')})
.appendTo(li);
and the resulting element is as follows:
<img id="6" src="images/16-arrow-right.png" class="expImg"/>
It completely eliminates the onclick function, but everything else works fine. Does anyone see a problem with my code, or is the error somewhere else? Thanks in advance...
source
share