我很难让两个jquery脚本一个接一个地工作
Im having trouble making two jquery scripts work one after the other
第二个脚本在使用第一个脚本加载后不起作用
我正试图用这个加载它
$(document).ready(function() {
$('div.frame ul#main li a').click(function(){
var toLoad = $(this).attr('href')+' #content';
$('#content').hide('fast',loadContent);
function loadContent() {
$('#content').load(toLoad,'',showNewContent())
}
function showNewContent() {
$('#content').show('normal',hideLoader());
}
function hideLoader() {
$('#load').fadeOut('normal');
}
return false;
});
});
一页加载后使用这个
$(document).ready(function(e) {
var currentportfolio = $('div#slider ul li:first-child').addClass('show');
var portfolio = $('div#slider ul li');
$('div#slider ul li').not(':first').hide();
$('.prev, .next').click(function() {
// Determine the direction, -1 is prev, 1 is next
var dir = $(this).hasClass('prev') ? -1 : 1;
// Get the li that is currently visible
var current = $('div#slider ul li:visible');
// Get the element that should be shown next according to direction
var new_el = dir < 0 ? current.prev('li') : current.next('li');
// If we've reached the end, select first/last depending on direction
if(new_el.size() == 0) {
new_el = $('div#slider ul li:'+(dir < 0 ? 'last' : 'first'));
}
// Hide them all..
$('div#slider ul li').hide();
// And show the new one
new_el.show();
// Prevent the link from actually redirecting the browser somewhere
return false;
});
});
我是jQuery的新手。提前谢谢。
查看.load
的文档。jQuery提供了一个"回调"函数作为.load
函数的一部分。回调基本上是在.load
完成后运行的。看起来你已经在用了。
http://api.jquery.com/load/
function showNewContent() {
$('#content').show('normal',hideLoader());
additionalStuffToDoAfterLoad();
}
function additionalStuffToDoAfterLoad(){
//all the stuff in section 2 goes here.
}
相关文章:
- 当单元格内容由于forumula从另一个工作表编译数据而更改时发送电子邮件
- 当源工作表添加了行时,如何编写在一个工作表中添加行的脚本
- 如何在jquery中为object键创建一个工作变量以避免额外的代码
- 是否有可能在 threejs 中创建一个工作的计算机界面
- Javascript .call() 用法.一个工作案例,一个不是.有什么区别
- 我可以在 MVC 3.0 中获得一个工作 Asp.NET jsTree 4 示例,并异步加载节点
- 将数据从一个工作表复制到另一个工作表;使用目标工作表中的复制数据创建一个表
- 即使我从另一个工作小提琴复制代码,JSFiddle 也不起作用
- dojo's registry.findWidgets() 的一个工作示例
- 根据条件将行从一个工作表复制到另一个工作表
- 你如何使用JavaScript制作一个工作时钟
- 网络音频Api:我如何添加一个工作卷积器
- 我想编辑一个工作的javascript代码来增加它的功能
- 多个谷歌图表,只有一个工作
- 选择一个工作的国家
- jQuery Ajax的两个相同的函数为其中一个工作,而不是另一个
- 两次相同的onclick功能-只有一个工作
- 是否有一个工作的qrCode阅读器在Js/Jquery那里
- 将一个工作的jQuery表单复制到另一个位置,但只复制原来的工作
- 在两个不同的工作表中查找具有相同列的选定行,并将其从其中一个工作表中删除