<div id = uni1>
<input type=button class=click rel="1">
</div>
<div id = uni2>
<input type=button class=click rel="2">
</div>
<div id = uni3>
<input type=button class=click rel="3">
</div>
<div id = uni4>
<input type=button class=click rel="4">
</div>
$(".click").click(function()
{
alert("Help");
})
i have problem identifying the click button for jquery this will prompt alert 4 times.
“#uni1 .click” will allow me to identify
BUT I CANNOT static DEFINE this.
MEAN i can only use .click. because MY uni1 <– is DYNAMIC i can have up to uni100.
or Uni10000(This is User Choice to have number of uni)
my question would be how am i going to identify uniquely each button for each input type.
after the button is click i can use
$(".click").click(function()
{
$(this).parent().attr('id');
//it doesn't solve the problem that alert will still be executed 4 times. i want to have click being uniquely identify upon user click.
alert("Help");
})
<div id=uni>
<div id = uni1>
<input type=button class=click rel="1">
</div>
<div id = uni2>
<input type=button class=click rel="2">
</div>
<div id = uni3>
<input type=button class=click rel="3">
</div>
<div id = uni4>
<input type=button class=click rel="4">
</div>
</div>
$("#uni"+i).load(abc.html,function(){ $(".click").click(funcion(){ alert("help");})})
I’ve tried your example and it works fine to me. http://jsfiddle.net/3yQ4W/
If it’s prompted 4 times it’s either because you’ve declared it 4 times or because you have some weird loop in there that you are not showing us.
EDIT: