当调用 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/