jquery - Check toggle state -
i want check toggle state. when check console log of browser, visible value true , doesn't change false.
why happening? , how can fix it?
<html> <head> <script src='~/scripts/jquery-1.4.1.min.js' type="text/javascript"></script> <script type="text/javascript"> $(function () { $('#divupdateform').click(function () { $('#divupdatecontent').slidetoggle(); console.log($('#divupdatecontent').is(":visible")); }); }); </script> </head> <body> <div id="divupdateform" runat="server" class="panel" >update panel state</div> <div id="divupdatecontent" runat="server"> ... content </div> </body> </html>
you need check before slide element, during slide, element visible:
$(function () { $('#divupdateform').click(function () { var v = $('#divupdatecontent').is(":visible") $('#divupdatecontent').slidetoggle(); // note variable v accessible here ? console.log(v) }); });
Comments
Post a Comment