[英]Can I have multiple jquery .load() event in one page?
Is this possible? 这可能吗? I've got one jquery file that is loaded in every page that uses the .load() event, but then a few select pages also require some specific jquery stuff where I'd like to use .load() again.
我有一个jquery文件加载到每个使用.load()事件的页面中,但是一些选择页面也需要一些特定的jquery东西,我想再次使用.load()。 Thanks for reading.
谢谢阅读。
Yep, that's no worries. 是的,这不用担心。
The events will run in the order they were defined: 事件将按照定义的顺序运行:
$(function() {
$('body').append('<span>A</span>');
});
$(function() {
$('body').append('<span>B</span>');
});
$(function() {
$('body').append('<span>C</span>');
});
The above would append "ABC" to the page. 上面会在页面上附加“ABC”。
Interestingly, if you use the long-hand method, it completes in a different order: 有趣的是,如果你使用长手法,它会以不同的顺序完成:
$(function() {
$('body').append('<span>A</span>');
});
$(document).ready(function() {
$('body').append('<span>B</span>');
});
$(function() {
$('body').append('<span>C</span>');
});
This outputs "ACB" 输出“ACB”
Even more confusingly, if you only use the longhand, then it appears as though the first handler runs last and the rest in order: 更令人困惑的是,如果你只使用了longhand,那么好像第一个处理程序最后运行而其余处理顺序如下:
$(document).ready(function() { /* A */ });
$(document).ready(function() { /* B */ });
$(document).ready(function() { /* C */ });
$(document).ready(function() { /* D */ });
$(document).ready(function() { /* E */ });
// BCDEA
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.