1//jQuery listen for checkbox change
2$("#myCheckBoxID").change(function() {
3 if(this.checked) {
4 //I am checked
5 }else{
6 //I'm not checked
7 }
8});
1const mutationObserver = new MutationObserver(mutationsList => {
2 mutationsList.forEach(mutation => {
3 if (mutation.attributeName === 'class') {
4 // classes have changed
5 }
6 });
7});
8
9mutationObserver.observe(
10 // a document object you want to watch. some examples of document objects:
11 // document.getElementById('id')
12 // document.getElementsByClassName('class')[5]
13 // document.querySelector('[query=selector]')
14 // etc
15 ,{ attributes: true }
16)
17
18// when you wanr to remove the listener
19mutationObserver.disconnect();
1document.getElementById('my-select').addEventListener('change', function() {
2 console.log('You selected: ', this.value);
3});
1<!--
2 You can use any of the following:
3 onkeydown, onkeyup or onchange
4 -->
5
6<input type="text" onkeydown="keydownFunction()"
7onkeyup="keyupFunction()" onchange="changeFunction()">
1$('#myTextAreaID').on('input propertychange paste', function() {
2 //my Textarea content has changed
3});