Toggle a switch from active(clicked) to inactive (not clicked) with JavaScript
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 {
special.fireEvent('onchange');
}
});
This code works perfectly..


Comments
Post a Comment