如何同时执行 2 个功能。在下面带有 onclick 的代码片段中,我获取了id
父 Div 的 ,然后使用id
,
<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)
}
});
}
});