나는이 코드를 가지고 있는데, 'Accept'버튼을 클릭하면 전체 <tr>
태그가 'display : none;'스타일로 숨겨지기를 원한다. 지금은 버튼이 <td>
을 숨기고 있기 때문에 나는 그런 식으로하고 싶지 않습니다. 전체 테이블 행을 숨기고 싶습니다.JavaScript로 부모의 부모 요소를 숨기는 방법은 무엇입니까?
<table class="table table-bordered">
<tr>
<th>Name</th>
<th>Username</th>
<th>Email</th>
<th>Skype</th>
<th>Phone</th>
<th>Message</th>
<th>Accept?</th>
</tr>
<tr style="">
<td>Name</td>
<td>Username</td>
<td>[email protected]</td>
<td>skypename</td>
<td>phone</td>
<td>MESSAGE</td>
<td><button onclick="this.parentElement.style.display='none';" class="btn btn-success">Accept</button> <button class="btn btn-danger">Deny</button></td>
</tr>
</table>
jQuery를 태그를 사용하지 마십시오을 그것을 사용하지 마십시오 –
'this.parentElement.parentElement.style.display = 'none''? –
'.parentElement'가 버튼에서'td'로 당신을 가져 오면'td'에서'tr'까지 어떻게 얻을 수 있다고 생각합니까? –