Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
145
rated 0 times [  150] [ 5]  / answers: 1 / hits: 109069  / 15 Years ago, tue, march 16, 2010, 12:00:00

I want to change the background color of the table cell when radio button inside the cell is clicked.



<table>
<tr>
<td align=center>
<input type=radio value=foo
onclick=this.parentElement.style.background-color='red'; />
</td>
</tr>
</table>


How to get the parent element reference?


More From » jquery

 Answers
238

Using plain javascript:



element.parentNode


In jQuery:



element.parent()

[#97326] Friday, March 12, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
caylasarinag

Total Points: 194
Total Questions: 107
Total Answers: 105

Location: Benin
Member since Sun, Jan 29, 2023
1 Year ago
;