Question: I have the following in my view:

```
<%=Html.RadioButton("optAll", "1", true)%> &nbsp Choose All
<br />
<%=Html.RadioButton("optAll", "2", false)%> &nbsp Choose Specific

```

Follows is the jquery:

```
$("#optAll").click(function () {
       alert ("Hitting the click function");
    });

```

The problem is that the alert only pops up when the "Choose All" radio button is clicked. It does not pop up when the "Choose Specific" radio button is clicked.

The following kind of works:

```
$(":input[@name='optAll']").change(function () {
       alert ("Hitting the click function");
    });

```

but this solution triggers the message when check boxes on the same page are clicked.

I've also tried the following with no luck:

```
$("#optAll").click(function () {
       alert ("Hitting the click function");
    });

```

Answer: 
If you have no more inputs with name `optAll`, the following should work:

```
$(":input[name='optAll']").change(function () {
   alert ("Hitting the click function");
});

```

if you have such inputs, you need to narrow your query. E.g:

```
$(":radio[name='optAll']").change(function () {
   alert ("Hitting the click function");
});

```
Since you are selecting by ID to set the click function, jQuery selects only one element (the first one in document with that ID). If you want to change just these two, change their IDs to be different and write a $('#id').click() for both of them. If you have several sets of these, and it would be a huge pain to write individual lines for each button and you would prefer one for each set, then give them similar IDs (such as "optALL1" and "optALL2" in this case) and use the following:

```
$('input[id|="optALL"]').each($(this).click(function() { alert(""); }))

```

where the input[id|="optALL"] will select all input elements whose id begins with "optALL"