two nested functions in jquery?
I'm not sure if this is actually possible but I would have thought it is. I am very new to jquery. What I am trying to do is nest two functions.
Hide the target div load the new page into the div open up the div again
This works if I place the initial slideToggle on its own but I want to make sure the page is loaded before opening again
function nickyLoad(siteToFetch开发者_JAVA技巧,whereToPut){
$('#'+whereToPut+'').slideToggle('slow', function() {// collapse target
$('#'+whereToPut+'').load(siteToFetch, function() { //load new site
$('#'+whereToPut+'').slideToggle('slow','');
});
)};
}
Many thanks!
You've mixed up the order of }
and )
when closing the first slideToggle call (you've written )};
instead of });
function nickyLoad(siteToFetch,whereToPut){
$('#'+whereToPut+'').slideToggle('slow', function() {// collapse target
$('#'+whereToPut+'').load(siteToFetch, function() { //load new site
$('#'+whereToPut+'').slideToggle('slow','');
});
}); //<-- corrected
}
These things (syntax errors) are easy to find with some simple tools. In firefox you can open the error console (Tools --> Error Console) and go to the "Error" tab. In Internet Explorer use the Developer Tools (Tools --> Developer Tools) and go to the "Script" tab.
Firebug for firefox is also highly recommended.
精彩评论