I have a quick jQuery question:
First, my HTML:
<div id="taskinput">
<form>
<input id="taskinput-box" type="text"></input>
<input type="submit"></input>
</form>
</div><!-- end taskinput -->
<div id="taskoutput"></div><!-- end taskoutput -->
I am creating content in the #taskoutput from user using .append while creating a new class, .task.
$("#taskinput").submit(function() {
var tasktext = $('#taskinput-box').val()
$('#taskoutput').append('<div class="task">'+tasktext+'</div>');
$('#taskinput-box').val("");
return false;
});
The above code works fine; the trouble arises when I try to select the created divs. The below code does not work:
$(".task").click(function() {
$(this).slideUp();
});
What am I missing?