tags:

views:

21

answers:

2

I have three radio buttons

<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" />

Which is the shortest possible way to do this:

IF RadioJ checked
do this
else if FaroK is checked
do that
else if MartreLK
do this and that

A: 

Something like this, maybe? (:

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
}
peirix
A: 
$(document).ready ( function () {
    $(".abc").click ( function (event) {
        var target = event.target.id;

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