jquery checkbox check not working -


i have small script,with straight function. if checkbox not checked, if user clicked on show div otherwise hide div when user clicks in it. script (its inside php code ):

echo  '<script>  $(document).ready(function(){  if($("#chk_id'.$bank_name.'").is(":checked")) {      $("#chk_id'.$bank_name.'").click(function(){       $("#form_show'.$bank_name.'").hide(300);    });  } else {       $("#chk_id'.$bank_name.'").click(function(){      //alert("ddd");      $("#form_show'.$bank_name.'").show(300);    }); } });       </script>'; 

but problem although show div working, unable hide div ! whats wrong? javascript library : <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

try this:

$(document).ready(function(){     $('body').on('click', "#chk_id'.$bank_name.'", function() {         if($("#chk_id'.$bank_name.'").is(":checked")) {             $("#form_show'.$bank_name.'").hide(300);         } else {             $("#form_show'.$bank_name.'").show(300);         }     }); }); 

Comments

Popular posts from this blog

c++ - Creating new partition disk winapi -

Android Prevent Bluetooth Pairing Dialog -

VBA function to include CDATA -