Reputation:
$("#foo").toggle(function(){alert("A");},function(){alert("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!
Upvotes: 0
Views: 1519
Reputation: 50974
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
Upvotes: 4