Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

javascript checkbox checked event

const checkbox = document.getElementById('myCheckbox')

checkbox.addEventListener('change', (event) => {
  if (event.currentTarget.checked) {
    alert('checked');
  } else {
    alert('not checked');
  }
})

//HTML INPUT VVVVVVVVVVVVVV
<input id="myCheckbox" type="checkbox" />
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #javascript #checkbox #checked #event
ADD COMMENT
Topic
Name
3+9 =