SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    Mar 2004
    0 Post(s)
    0 Thread(s)

    Assign class to parent when child is clicked or hovered over

    I'm using a tab navigation script that assigns a class to the selected tab and a tab that's hovered over. For my particular layout I require the tab function to work on a span within each list item.

    Please take a look here

    I need to change the background of the parent li of a hovered-over or selected span, and need help achieving this. I thought that maybe the parent could also be assigned 'selected' or 'hover' as a class (CSS for this scenario included). But there might be a cleverer option?

    Ideally, this should be done outside the moo_tabcontrol.js script, and also without jQuery. I would be very grateful for any help here as I'm rather illiterate when if comes to Javascript. Many thanks.

  2. #2
    SitePoint Guru Vincent Puglia's Avatar
    Join Date
    Feb 2000
    where the World once stood
    0 Post(s)
    0 Thread(s)
    Not positive of what you're asking for, nor am I certain it would work (since I can't replicate the same code) but is this along the lines?
    <li><span onclick="doParent(this)">Retina</span></li>
    function doParent(obj) { = "red";
    Where the World Once Stood
    the blades of grass
    cut me still


Posting Permissions

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