Page is a not externally linkable
- Code, Content, and Presentation
-- JavaScript and AJAX
---- Append text and value using JQuery


rwilson - 8:40 pm on Mar 26, 2012 (gmt 0)


When I try to use the ".deleteThis" function it doesn't work on <li> tags created after page load. Is there a way I can apply the function to new <li> tags?

$('#edit').submit(function() {
$('#output').append('<li><span contenteditable="true">' + $('#editInput').val() + '</span><span class="deleteThis">X</span></li>');
localStorage.setItem('todoData', $('#output'));
return false;
});

$(".deleteThis").click(function() {
alert('Handler for .deleteThis() called.');
//$("li").remove();
$(this).parent('li').hide();
});
});


Thread source:: http://www.webmasterworld.com/javascript/4433354.htm
Brought to you by WebmasterWorld: http://www.webmasterworld.com