开发者

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜