Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Handle Radio Button List Option change with jQuery

I hava a RadioButtonList control on my page that has multiple option.I want to handle change of its options and, according to value of selected option, do work.

This does not work:

 $(document).ready(function () {
        $('#RadioButtonList1').change(function () {
            if ($(this).is(':checked')) {
                alert("yes");
            }
        });
    });

How I can Handle that?

thanks

like image 538
Arian Avatar asked Dec 01 '22 07:12

Arian


1 Answers

You just need to bind the inputs themselves, not their group:

$(document).ready(function () {
    $('#RadioButtonList1 input').change(function () {
        // The one that fires the event is always the
        // checked one; you don't need to test for this
        alert($(this).val());
    });
});
like image 125
Interrobang Avatar answered Dec 05 '22 01:12

Interrobang