I am trying to run two different jQuery/Java Scripts under one file name... And when I do they do not seem to work hand-in-hand one works and the other doesn't.
I have a page that requires both the scripts, so I tried putting those two in one file. That doesn't work, but when I split them up, they seem to work...
I know very little about JavaScript and jQuery can someone guide me into allowing these two scripts not to conflict?
$(document).ready(function($) {
$(".myslider").slideshow({
width : 643,
height : 303,
control : false,
transition : 'squarerandom',
});
$(document).ready(function() {
$('.navigation .submenu > li').bind('mouseover', openSubMenu);
$('.navigation .submenu > li').bind('mouseout', closeSubMenu);
function openSubMenu() {
$(this).find('ul').css('visibility', 'visible');
};
function closeSubMenu() {
$(this).find('ul').css('visibility', 'hidden');
};
});
I bet you can guess the two scripts. Thanks! Aaron
-
3Sorry but I think we're going to need more info than this. What "doesn't work"? Do you get an error? What is the error? Don't make us 'guess' the two scripts. What does your html look like? Provide more info and we'll be better able to help you out.kasdega– kasdega2011年12月09日 20:00:20 +00:00Commented Dec 9, 2011 at 20:00
2 Answers 2
Your syntax is off. Try this:
$(document).ready(function() {
$(".myslider").slideshow({
width : 643,
height : 303,
control : false,
transition : 'squarerandom',
});
$('.navigation .submenu > li').bind('mouseover', openSubMenu);
$('.navigation .submenu > li').bind('mouseout', closeSubMenu);
function openSubMenu() {
$(this).find('ul').css('visibility', 'visible');
};
function closeSubMenu() {
$(this).find('ul').css('visibility', 'hidden');
};
});
No need for 2 different document.readys, plus you weren't closing one of them.
4 Comments
You have a syntax error: transition : 'squarerandom', shouldn't have a trailing comma.
That makes the entire file invalid.