Reputation: 8188
I am having trouble getting the onmouseover function working in jquery. What I want to do is when you hover over the word "here" the image pops up. The plugin is working fine just don't know how to handle the onmouseover or hover event?
HOVER ISNT WORKING IN MY CODE
('a.lightbox').hover(function(){
$('a.lightbox').lightBox();
});
<body>
<form id="form1" runat="server">
<div id="outer">
<a href="image1.jpg" class="lightbox">here</a>
</div>
</form>
</body>
This doesnt work either.....
$('a.lightbox').hover(function() {
$(this).lightBox();
});
Isn't there something where I can simply hover over a word and an image pops up?
Upvotes: 0
Views: 320
Reputation: 745
You forgot the $. Try this
$('a.lightbox').hover(function(){
$('a.lightbox').lightBox();
});
Also, you can use $(this).lightBox();
instead for the second line.
Here's an example: http://api.jquery.com/hover/#hover2
Upvotes: 0
Reputation: 2256
Hey you missed the '$' sign of jQuery
see for demo http://jsfiddle.net/Vjhz3/7/
Upvotes: 1
Reputation: 78900
In addition to the issue @mahesh found, you should also not use the hover
function; when using hover
with one function, your function is used when the mouse both enters and leaves the element. Use the mouseenter
or mouseover
events instead.
Upvotes: 0
Reputation: 520
In addition to missing the $ sign, this code will not work because it will open all elements with the selector a.lightbox, not just the one hovered on, try this:
$('a.lightbox').hover(function(){
$(this).lightBox();
});
Upvotes: 0
Reputation: 6641
Two things here...
$('a.lightbox')
on the first line, not ('a.lightbox')
Upvotes: 1