同時に 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)
}
});
}
});