View Full Version : onclick event doesnt seem to access the parentnode

04-09-2014, 12:46 AM
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.

<div id="wrapper>
<div class="circle assessment">
<h2>Assess And Plan</h2>
<div class="circle_big">
<h2>Assess And Plan</h2>
<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>

<a onclick="this.parentNode.style.display = 'none';">Click Me</a>

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

Uncaught TypeError: Cannot read property 'style' of undefined

Any help is appreciated.

Thanks in advance.

04-09-2014, 04:37 AM
Works fine here:


Any particular browser/version giving you trouble?

04-19-2014, 11:17 PM
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