如果我们在js文件中将同一个div绑定两次,而将一个div作为内联脚本绑定,会发生什么 [英] what happens if we bind the same div twice one in js file and one as inline script
本文介绍了如果我们在js文件中将同一个div绑定两次,而将一个div作为内联脚本绑定,会发生什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
这是在javascript文件中
this is inside javascript file
如果我对同一个div定义了两次相同的绑定,会发生什么//
what happenes if i have the same bindings for the same div defined twice //
$(document).ready(function() {
$("#divid").click(function() {
// some logic here
});
});
这是内联的
<script language="javascript" type="text/javascript">
$(document).ready(function() {
$("#divid").click(function() {
// some logic here
});
});
</script>
推荐答案
结果将是两个处理程序都将运行他们被绑定的顺序(除非第一次中断事件,例如 return false
)。
The result will be that both handlers will run, in the order they were bound (unless the first interrupts the event, e.g. return false
).
他们受约束的顺序是< script>
元素出现的顺序,因为 .ready()
处理程序也按顺序排队。
The order they're bound is the order the <script>
elements occur in, since .ready()
handlers are also queued in order.
这篇关于如果我们在js文件中将同一个div绑定两次,而将一个div作为内联脚本绑定,会发生什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文