Jquery: Click event doesn't work after append. (Don't know how to use .ON) -


i have 2 click events. 1 appends img includes click event. doesn't work obviously. know have use jquery's .on, can't figure out how , where.

my code:

$( document ).ready(function() {     // 1 below (.choimh) isn't triggered anymore     $('.choimg').click(function(){      });      // switch chosen color     $('.color').click(function(){         $(".thumbs").append('<a href="#"><img id="image'+u+'" class="choimg" src="/img/products/mini/'+colnumber+'-'+ + '.jpg" />');     }); }); 

the .color div on different place .choimg.

i can't figure out how use .on.

it used live or delegate functions did kind of thing. can this:

$(document).on('click', '.choimg', function(e) {  //do whatever  }); 

Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -