Results 1 to 3 of 3

Thread: onclick event doesnt seem to access the parentnode

  1. #1
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default onclick event doesnt seem to access the parentnode

    So I am tweaking a script that takes an onClick and shows a hidden div. These were originally accomplished through mouseenter. I was hoping to just use a style change to hide the parent element once it is clicked.

    Code:
    i.e. 	
    <div id="wrapper>
    <div class="circle assessment">
    		<h2>Assess And Plan</h2>
    		<div class="circle_big">
    			<h2>Assess And Plan</h2>
    			<ul>
    				<li>Lorem ipsum dolor sit amet.</li>
    				<li>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Proin. </li>
    				<li>Lorem ipsum dolor sit amet, consectetur adipiscing.</li>
    			</ul>
    			
    			<a onclick="this.parentNode.style.display = 'none';">Click Me</a>
    		</div>
    </div>
    I want to make the circle_big class disappear on the click of the href. Not quite sure what i am doing wrong . If I reference the parent of the parent everything disappears. With this usage I keep getting an
    Code:
    Uncaught TypeError: Cannot read property 'style' of undefined
    Any help is appreciated.

    Thanks in advance.
    Last edited by itivae; 04-09-2014 at 12:51 AM.

  2. #2
    Join Date
    Mar 2005
    Location
    SE PA USA
    Posts
    30,495
    Thanks
    82
    Thanked 3,449 Times in 3,410 Posts
    Blog Entries
    12

    Default

    Works fine here:

    http://home.comcast.net/~jscheuer1/s...rentnode-h.htm

    Any particular browser/version giving you trouble?
    - John
    ________________________

    Show Additional Thanks: International Rescue Committee - Donate or: The Ocean Conservancy - Donate or: PayPal - Donate

  3. #3
    Join Date
    Nov 2009
    Posts
    107
    Thanks
    7
    Thanked 2 Times in 2 Posts

    Default

    jscheuer1 Thanks for taking a look. I got swamped last week and was unable to reply. I figured out a better work around than inline Javascript. The above example worked (kind of) in Opera and IE but not in FF and Chrome. Weird. All set now though. Thanks again for replying

Similar Threads

  1. Onclick event
    By william james in forum JavaScript
    Replies: 4
    Last Post: 01-10-2011, 04:46 PM
  2. Help w/ onClick event
    By integer in forum JavaScript
    Replies: 1
    Last Post: 02-19-2010, 04:36 AM
  3. Onclick event -> onload event
    By Goodboy in forum JavaScript
    Replies: 0
    Last Post: 08-31-2009, 01:30 PM
  4. Onclick event for a link...
    By jnscollier in forum JavaScript
    Replies: 6
    Last Post: 03-24-2007, 09:18 PM
  5. Replies: 2
    Last Post: 10-05-2006, 11:38 AM

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
  •