[jQuery] selectors, events, and scripted elements not working
Hello,
I am having some problems with selectors and events. I have a row of
thumbnails all part of the "thumbnails" class. I'm trying to run some
code when a thumbnail is clicked, but something weird is happening.
When i use this selector/event:
" $(".thumbnails").click(function(){ // run some code });
nothing happens.
I've tested this:
" $("img").click(function(){ // run some code });
And the code does run on what seems like all <img> that are set in the
HTML doc, but not the <img> elements that are created from JQuery
script.
Can anyone help to explain this? What am I doing wrong here?
For reference:
The jquery script creating elements is:
$(function(){
var image = new Image();
$(img).attr('src', path)
$(img).attr('class', "thumbnails");
$('#thumbnailwrapper').append(img);