javascript - 调用某个函数时执行 jQuery

标签 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>

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

最佳答案

看到更新后的问题后,处理此问题的唯一方法是将您的 jquery 函数置于与函数 foo() 相同的级别,并从那里调用它,如 this example 中所述。 .

关于javascript - 调用某个函数时执行 jQuery,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31857970/

相关文章:

javascript - 仅在需要时加载 javascript 函数

javascript - 浏览器中音频 MediaStream 的当前带宽或质量是多少? (WebRTC)

javascript - 进度条 : how to make color transition according to the progress?

javascript - 想要使用减号图标关闭侧面板

javascript - 使用 Javascript 创建带有 JSON 信息的网站链接?

javascript - 当用户在文本框中输入地名时,多边形轮廓会出现在地点边框上

javascript - 当上面的行使用 rowspan 时隐藏第 2 列

javascript - 添加更多输入的唯一名称

javascript - 一次切换一个元素时遇到问题 (jQuery)

html - 加载到 TWebBrowser 中的 html 文档的总高度