SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    971
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Return element with highest z-index

    I'm using the jquery topZIndex plugin in my application. It's working great.

    Now I have a situation though, where I would like to return the element with the highest z-index on the page. The plugin has a function that will return the highest z-index, but it's a value, not an object.

    Any help is appreciated, thanks.
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    Unobtrusively zen silver trophybronze trophy
    paul_wilkins's Avatar
    Join Date
    Jan 2007
    Location
    Christchurch, New Zealand
    Posts
    14,682
    Mentioned
    99 Post(s)
    Tagged
    4 Thread(s)
    Quote Originally Posted by downtroden View Post
    I'm using the jquery topZIndex plugin in my application. It's working great.

    Now I have a situation though, where I would like to return the element with the highest z-index on the page. The plugin has a function that will return the highest z-index, but it's a value, not an object.
    It looks like it's going to be a different plugin that you need then.
    Programming Group Advisor
    Reference: JavaScript, Quirksmode Validate: HTML Validation, JSLint
    Car is to Carpet as Java is to JavaScript

  3. #3
    Non-Member
    Join Date
    Apr 2011
    Location
    no fixed address
    Posts
    851
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You should be able to do it fairly easily without jQuery.

    Code:
    document.getElementsByTagName('*')
    returns all the element objects on the page. Then loop through them to find the one with the highest z-index.

    Shouldn't be more than a handful of lines of code, max.


Bookmarks

Posting Permissions

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