Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jquery 对radiobutton采取行动的最短可能方式_Jquery - Fatal编程技术网

Jquery 对radiobutton采取行动的最短可能方式

Jquery 对radiobutton采取行动的最短可能方式,jquery,Jquery,我有三个单选按钮 <input id="RadioJ" type="radio" name="grp1" class="abc" /> <input id="FaroK" type="radio" name="grp1" class="abc" /> <input id="MartreLK" type="radio" name="grp1" class="abc" /> 哪种方法是实现此目的的最短方法: 如果已选中RadioJ 这样做 否则,

我有三个单选按钮

<input id="RadioJ"    type="radio" name="grp1" class="abc" />
<input id="FaroK"    type="radio" name="grp1" class="abc" />
<input id="MartreLK" type="radio" name="grp1" class="abc" />

哪种方法是实现此目的的最短方法:

如果已选中RadioJ
这样做
否则,如果选中FaroK
那样做
否则,如果MartreLK

也许可以做这样那样的事情?(:

var chkd = $("input[name=grp1]:checked").attr("id");
if (chkd === "RadioJ") {
  //do this
} else if (chkd === "FaroK") {
  //do that
} else if (chkd === "MartreLK") {
  //do this and that
} else {
  //nothing is checked
}
$(document).ready ( function () {
    $(".abc").click ( function (event) {
        var target = event.target.id;

        if ( id === 'RadioJ' )
        {
        }
        else if ( id === 'FaroK' )
        {
        }
        else if ( id === 'MartreLK' )
        {
        }
    });
});