Results 1 to 4 of 4

Thread: [RESOLVED] Get hover status

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    233

    Resolved [RESOLVED] Get hover status

    hi guys, how to get the hover status of a particular element? let's say i got a, b, c, and d links.. how to check which element got an active hover status or has the focus?
    is it possible? thank you for any ideas...
    The taller the bamboo grows the lower it bends...

  2. #2
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: Get hover status

    Using jQuery:

    Code:
    $('a').mouseenter(function(){
        // "this" refers to the element that has been entered
    });
    
    $('a').focus(function(){
        // "this" refers to the element that has been focused
    });
    
    $('a').mouseleave(function(){
        // "this" refers to the element that has been left
    });
    
    $('a').blur(function(){
        // "this" refers to the element that has lost focus
    });
    You can also match elements that currently have a focus or hover:

    $('a:hover,a:focus').dowhateveryouwanttodo

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2009
    Posts
    233

    Re: Get hover status

    thanks
    The taller the bamboo grows the lower it bends...

  4. #4
    VB6, XHTML & CSS hobbyist Merri's Avatar
    Join Date
    Oct 2002
    Location
    Finland
    Posts
    6,654

    Re: [RESOLVED] Get hover status

    Just a further tip that comes to my mind: to keep code simple you could change focus on mouseenter to the element that has been entered. This in turn would mean you only need to do any visual changes in the focus and blur events plus keyboard access would work automatically – tabbing to next element or browser specific stuff, I think Opera has it's own way of handling browsing links. Whether this works for you depends on what you want to do, but it is an alternative idea for keeping code as short and maintainable as possible. jQuery after all does nearly all the cross-browser stuff so you don't need to bother about that

Posting Permissions

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



Click Here to Expand Forum to Full Width