在调用某个函数时执行jQuery

时间:2015-08-06 14:08:44

标签: javascript jquery html event-handling

当我调用JavaScript中的其他一些函数时,我想在jQuery中执行一些任务。

解释这个问题:我们说我在JavaScript中有function foo(){..}

虽然我的代码处于执行阶段,但我想在调用function foo(){..}时使用jQuery执行一些操作。

粗略演示:

    <!DOCTYPE html>
    <title>Demo</title>
    <body>
    <script>
    function foo()
    {
        alert("Function Called");
    }

    ...Some code....
if(some condition)    
    foo();   //function Call   - I want to execute jQuery event when this line is executed.
else
    woo();
    </script>
    </body>
    </html>

是否有可以实现此目的的事件处理程序?

1 个答案:

答案 0 :(得分:0)

在看到更新的问题之后,处理这个问题的唯一方法是将你的jquery函数放在与函数foo()相同的级别,并按照this example中的说明从那里调用它。