O'Reilly logo

jQuery and JavaScript Phrasebook by Brad Dayley

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Handling Selection Changes

$("select").on("change",   function(e) {     select_change_code_here }); $("input[type=checkbox]").on("change",   function(e) {     checkbox_change_code_here }); $(" input[type=radio]").on("change",   function(e) {     radio_change_code_here });

Another important type of event to handle when working with forms is the selection change in check boxes, radio inputs, and select elements. All these elements have a change event handler that is triggered when the selection changes.

To handle selection changes on these items in jQuery, add the following event handler. Then put whatever change code you would like inside the handler function:

$("#formElement").on("change", ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required