eKini: Web Developer Blog

PHP, MySQL, Javascript, MVC, Zend Framework, AJAX, jQuery

jQuery: How to handle radio buttons

July3

Here is a quick tutorial on how to handle radion buttons using jQuery.

< input type="radio" name="empType" value="regular" /> Regular
< input type="radio" name="empType" value="temporary" /> Temporary

Then the jQuery code: (assuming that you have already included the JS file in the header…)

 $("input[@name='empType']").change(
        function() {
            if ($("input[@name='empType']:checked").val()) {
                alert($("input[@name='empType']:checked").val());
            }
        }
    );
posted under General | 3 Comments »