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 5 of 5
  1. #1
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Grr... Need to reference the parent DIV

    Ok, I've not exactly at guru status when it comes to Javascript, so I need some help with this seemingly simple task:

    I've got this:

    <div style="...">
    <div>Stuff here</div>
    </div>

    What I need to do is have an onclick event on the nested DIV that can change the overflow properties of its "parent" DIV. I thought this.parent.style would be the way to go, but apparently not.

    So how do I reference that?

    PS: I don't want to use IDs, as these boxes are going to be dynamically generated.

    Thanks

  • #2
    Master Coder
    Join Date
    Feb 2003
    Location
    Umeå, Sweden
    Posts
    5,575
    Thanks
    0
    Thanked 83 Times in 74 Posts
    elm.parentNode
    liorean <[lio@wg]>
    Articles: RegEx evolt wsabstract , Named Arguments
    Useful Threads: JavaScript Docs & Refs, FAQ - HTML & CSS Docs, FAQ - XML Doc & Refs
    Moz: JavaScript DOM Interfaces MSDN: JScript DHTML KDE: KJS KHTML Opera: Standards

  • #3
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Moocho gracias

  • #4
    Kor
    Kor is offline
    Red Devil Mod Kor's Avatar
    Join Date
    Apr 2003
    Location
    Bucharest, ROMANIA
    Posts
    8,478
    Thanks
    58
    Thanked 379 Times in 375 Posts
    PS: I don't want to use IDs, as these boxes are going to be dynamically generated.
    Hm... I don't see why an ID can prevent from dinamically generate something....
    KOR
    Offshore programming
    -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*

  • #5
    Senior Coder
    Join Date
    Feb 2003
    Location
    Ontario, Canada
    Posts
    1,223
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Was sort of aiming for anonymous objects if that makes any sense. Just wanted to apply the onclick event to a DIV and have it know what to do without having to give it an ID.

    Meh. I'm using IDs anyways. Still using the parentNode though.


  •  

    Posting Permissions

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