开发者

jquery call/run toggle

开发者 https://www.devze.com 2023-03-31 05:33 出处:网络
$(\"#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 o
$("#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

精彩评论

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