javascript - check toggle and check default -
anybody have better way write jquery method. if user comes page , checkbox checked, show else hide, if user clicks checkbox display.
$('#rush').is(':checked') ? $("#rushjustificationcontainer").show() : $("#rushjustificationcontainer").hide(); $('#rush').click(function() { $("#rushjustificationcontainer").toggle(this.checked); });
use this
document.ready(function(){ mytoggle($('#rush').is(':checked')); } $('#rush').click(function(){ mytoggle(this.checked); } function mytoggle(ischecked) { if(ischecked) { $("#rushjustificationcontainer").show(); } else { $("#rushjustificationcontainer").hide(); } }
Comments
Post a Comment