Posts

Showing posts from January, 2018

Toggle a switch from active(clicked) to inactive (not clicked) with JavaScript

Image
Toggle a switch from active(clicked) to inactive (not clicked) with JavaScript   $(" #btnclear ").click( function (e) {                      var special = document.querySelector(' #Input-button-id ');         if (localStorage.backgroundModeOption == 1) {             $(special).attr(" checked ", true );         } else {             $(special).attr(" checked ", false );         }         if (typeof Event === 'function' || !document.fireEvent) {             var event = document.createEvent(' HTMLEvents ');             event.initEvent(' change ', true , true );             special.dispatchEvent(event);         } else {       ...