[jQuery] Why this simple code doesn't work ?!?
Hi, I have this simply code and I don't know where is the problem:
The script:
**************************************
$(document).ready(function(){
$('#button').click(function(){
var data = '<input type="button" value="push"
class="new_button"><br />';
$('#test').append(data);
lets_go();
});
});
function lets_go(){
$('.new_button').click(function(){
alert ('hello');
});
}
***********************************
And the HTML:
***********************************
<input type="button" id="button" value="make a new button" />
<br /><br /><br />
<div id="test"></div>
************************************
Ok, that's all.
Why when I make a few buttons and click, the alert-box pops as many
times as buttons are below?
Test on Firefox.
How can I resolve this??
Thanks a lot!