samedi 7 octobre 2017

How to bind to checkbox checked event

How to run javascript code if checkbox is checked?

checkbox is defined as

    <input type="checkbox" id="Maksja_piiratudes" name="Maksja_piiratudes" 

onfocus="if(typeof this.ischanged=='undefined') this.ischanged=false" onblur="summarefresh()" onclick="dataChanged(this)">

I tried

$(function () {
alert('checkbox is checked');

});  // end on change
}); // end $

But this runs also if checkbox is unchecked. How to run code only if checkgox is selected ?

Bootstrap 3, jquery, jquery UI are used.

Aucun commentaire:

Enregistrer un commentaire