jquery call/run toggle
$("#foo").toggle(function(){alert("A");},function(){al开发者_JAVA技巧ert("B");});
I would like to call this toggle so the "A" part will be run (alert A) and the "B" part will be the next one (if I click on foo). Is it possible? Thanks for help!
Your script is already doing it
http://sandbox.phpcode.eu/g/5f57f
<div id="foo">test</div>
<script>
$(function(){
$("#foo").toggle(function(){alert("A");},function(){alert("B");});
$("#foo").click();
});
</script>
alerts A,B,A,B,A,B on clicking, A on startup
精彩评论