Calling a function in jQuery with click()

前端 未结 1 1388
囚心锁ツ
囚心锁ツ 2020-12-04 21:29

In the code below, why does the open function work but the close function does not?

$(\"#closeLink\").click(\"closeIt\");
<         


        
1条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-04 21:58

    $("#closeLink").click(closeIt);
    

    Let's say you want to call your function passing some args to it i.e., closeIt(1, false). Then, you should build an anonymous function and call closeIt from it.

    $("#closeLink").click(function() {
        closeIt(1, false);
    });
    

    0 讨论(0)
提交回复
热议问题