0
如何在同一时间执行2个功能。在下面的onclick的代码片段,我得到父Div的id
,然后使用id
执行功能,在一个点击处理程序中执行2个功能
<div id="selDe">
<input type="radio" class="ger" id="num1" checked><label for="num1">
<input type="radio" class="ger" id="num2"><label for="num2">
</div>
<div id="selRe" >
<input type="radio" class="ger" id="num1" checked><label for="num1">
<input type="radio" class="ger" id="num2"><label for="num2">
JS:
<script>
$(".ger").on({
click:function(){
var pid = $(this).parent().attr("id"); //get the name of the div parent
$("#"+pid+" .ger").on({
//execute the function, but it just works after the next click
click: function() {
var showV = this.id.slice(3);
alert(showV)
}
});
}
});
我不认为这是可能的在JS – Adrift 2013-05-01 17:17:56
ID应该始终是独一无二的....这就是为什么它被称为“ID” – bipen 2013-05-01 17:19:13
我认为你的意思是“在一个点击处理程序”,而不是“在同一时间”。这是完全可能的。 – 2013-05-01 17:19:42