Hi,

I have the following code which aims to change the color of a parent div when the user unselects the radio button. However it doesn't work.

<div class="jquerycorner"><input type="radio" name="hat" value="4" onblur="if(!this.checked) { this.parentNode.style.backgroundColor='#000000';}">10</div>

However the following code works when I try to detect radio button selection.

<div class="jquerycorner"><input type="radio" name="hat" value="1" onclick="this.parentNode.style.backgroundColor='#FFC0CB';">5</div>

Any ideas?

nope, but will keep working on it.

why dont u rather implement a function on the onlick event.
I personally dont like using the onblur event.

Thanks Thirusha,

I indeed solved the problem using an onclick event.

Thank you!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.