<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");
})
我在识别 jquery 的单击按钮时遇到问题,这将提示警报 4 次。“#uni1 .click”将允许我识别但我不能静态定义它。意思是我只能使用.click。因为我的 uni1 <-- 是动态的,所以我最多可以拥有 uni100。或 Uni10000(这是拥有 uni 数量的用户选择)
我的问题是我将如何为每种输入类型唯一地识别每个按钮。单击按钮后,我可以使用
$(".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");})})