Possible Duplicate:
jQuery click not working for dynamically created items
$(document).ready(function(){
$('#btn').click(function(){
var createInput=$("<input type='button'>");
createInput.attr("id","close1");
createInput.attr("value","close");
$('#outer-div').append(createInput);
});
$("#close1").click(function(){
alert('hi');
});
});
</script>
</head>
<body>
<div id='outer-div'>
<input id='btn' type='button' value='click here'/>
</div>
What's wrong with the code. I am not getting the alert when i click the dynamically generated button named as close. Please help it out