I am attempting to implement the suckerfish menu found on this tutorial. I get “object expected” error from the sample javascript:
$(document).ready(function () {
$("#nav-one li").hover(
function () { $("ul", this).fadeIn("fast"); },
function () { }
);
if (document.all) {
$("#nav-one li").hoverClass("sfHover");
}
});
I have imported the JQuery using:
<script type="text/javascript" src="~/Scripts/jquery-1.4.1.js"></script>
The JQuery import is in the page header. The javascript is just inside the <body>.
It would be nice if I could tell which object is having the issue instead of being pointed at this block of code. I’m new to JQuery and beginner level javascript.
UPDATE
The start of the menu:
<ul id="nav-one" class="nav">
<li>
<a href="#item1">item 1</a>
<ul>
(I think the #nav-one points to the id of the menu “nav-one”).
And I believe this css covers the “sfHover” part:
#nav-one li.sfHover a {
background: #ccc;
color: #000;
}
The ‘object expected’ error can occur when you are not including jQuery correctly. Do you have that ‘jquery-1.4.1.js’ file in the directory the
srcattribute is pointing to?To test if this is the problem, try replacing your jQuery include with this:
That will request jQuery from Google’s servers.
Edit:
If I use your example code and the jQuery include I mentioned above, I don’t get that error. But you’ll also need to include the
part from your example. That defines
hoverClassas a jQuery method (it is not part of that standard jQuery library).