Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New Coder
    Join Date
    Apr 2009
    Location
    San Diego, CA
    Posts
    64
    Thanks
    2
    Thanked 1 Time in 1 Post

    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);
    });

  • #2
    New Coder
    Join Date
    Apr 2009
    Location
    San Diego, CA
    Posts
    64
    Thanks
    2
    Thanked 1 Time in 1 Post
    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...

  • #3
    New Coder
    Join Date
    Apr 2009
    Location
    San Diego, CA
    Posts
    64
    Thanks
    2
    Thanked 1 Time in 1 Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •