click - jquery add and remove elements -


this question has answer here:

i've been doing work on jquery script of mine. have image , when clicked append input type text.

$(document).ready(function() {

$('.addparticipant').click(function() {      $('.addparticipantdiv').append('<p><img src="images/iconminus.jpg" style="width:38px; height:38px;cursor:pointer;position:absolute;margin-top:5px;-moz-border-radius: 4px;border-radius: 4px;" class="removeparticipant"/><input type="text" name="ck_email" class="mailitem" style="width:170px;background:#fff; margin-left:40px"/></p>');  });  $('.removeparticipant').click(function() {      alert('oi');  }); 

});

however i've noticed not work since trying call click event on element has been created dynamically append. solution challenge? alert or .removeparticipant not work.

you need use jquery .on() (it .live() before, that's deprecated)


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -