I am working with an external JavaScript plugin that I can not edit and works by click on the a list of thumbnail images.
For styling purpose I have had to wrap the images in an <a> with:
if(img.parent("a").length == 0){
img.wrap('<a />');
}
Is there a way I can add a click for the <a> I have inserted which then makes this JavaScript plugin call the actions for click on a image.
I have tried this although doesn’t work and gives the error: Too much recursion:
$("#thumbs a").live("click", function(){
$(this).find("img").click();
});
Yes.
You also don’t need to say
if (something.length == 0)because it will return 0 by default…so you could say,if (!something.length)