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

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -