jquery - Why is the class of my dynamically created element not recognised? -


this question has answer here:

i have textbox. if selected , hit tab key, new line open. works fine far. however, same action doesn't work in dynamically created textbox. if has same class original textbox called on. tried find explanation on internet, couldn't get/understand right answer. please me?

http://jsfiddle.net/rzclm/1/

$('.list').keydown(function(key){     if(key.which === 9) {         $('.ingredients_list').append('<li><input class="list" type="text"/><i><img class="remove" src="images/remove.svg"></i></li>');      } });  

use $(document).on target dynamically created elements:

$(document).on('keydown', '.list', function(key){     if(key.which === 9) {         $('.ingredients_list').append('<li><input class="list" type="text"/><i><img class="remove" src="images/remove.svg"></i></li>');      } });  

jsfiddle.


Comments

Popular posts from this blog

How to logout from a login page in asp.net -

Stack level too deep error after upgrade to rails 3.2 and ruby 1.9.3 -