Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 01-21-2010, 05:39 PM   PM User | #1
Gremlyn1
New Coder

 
Join Date: Apr 2009
Location: San Diego, CA
Posts: 64
Thanks: 2
Thanked 1 Time in 1 Post
Gremlyn1 is an unknown quantity at this point
Give focus on mouseover

I'm trying to create a div that will slide down when moused over, but stay there until the user clicks somewhere else on the screen. I have it sliding down and displaying properly, but the .blur function will only fire if the element has focus and then loses it, which at the moment requires me to superfluously click the element and click off of it to get the div to slide up. Is there any way I can apply focus to the element with the mouseover function?

Code:
$j("#userlink").mouseover(function() {
	$j("#userinfo").slideDown(400);
}).blur(function() {
	$j("#userinfo").slideUp(400);
});
Gremlyn1 is offline   Reply With Quote
Old 01-21-2010, 05:50 PM   PM User | #2
Gremlyn1
New Coder

 
Join Date: Apr 2009
Location: San Diego, CA
Posts: 64
Thanks: 2
Thanked 1 Time in 1 Post
Gremlyn1 is an unknown quantity at this point
OK, after a little more trial and error, it is as simple as:
Code:
$j("#userlink").mouseover(function() {
	$j("#userinfo").slideDown(400);
	$j("#userlink").focus();
}).blur(function() {
	$j("#userinfo").slideUp(400);
});
However, the div won't stay open when I try to click on the input fields since the link loses focus. I tried giving the whole containing div focus, but it for some reason would not slide up when clicking elsewhere...
Gremlyn1 is offline   Reply With Quote
Old 01-21-2010, 06:10 PM   PM User | #3
Gremlyn1
New Coder

 
Join Date: Apr 2009
Location: San Diego, CA
Posts: 64
Thanks: 2
Thanked 1 Time in 1 Post
Gremlyn1 is an unknown quantity at this point
While it's not exactly what want, using .hover() on the containing div works well enough for now until I can figure out how to get the thing to stay open with appropriate focus assigned.
Gremlyn1 is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 04:46 AM.


Advertisement
Log in to turn off these ads.