我有一些問題,在這裏讓我的HTML表格改變單一td
`單擊td時更改bgcolor?
$(document).ready(function(){
$("#table1 > td").click(function(){
$(this).toggleClass("active");
});
});
table td.active {
background: #006633;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.0.0/jquery.min.js"></script>
<table width="100%" border="0" id="table1">
<tr>
<td colspan="6" height="20px" bgcolor="#CCCCCC"><strong>CULTURE</strong></td>
</tr>
<tr>
<td width="5%"><p align="center">1</p></td>
<td width="40%">Is the CDP obvious - You Said/We Did Boards; Feedback Stations; Posters?</td>
<td width="5%" height="20px"><p align="center">1</p></font></td>
<td width="5%" height="20px"><p align="center">2</p></font></td>
<td width="5%" height="20px"><p align="center">3</p></font></td>
<td width="5%" height="20px"><p align="center">4</p></font></td>
</tr>
</table>
when the
td`被點擊。由於某些原因,當它被點擊時,它什麼也不做。任何人有任何想法,爲什麼這是?
'td'不是'table'的直接孩子。使用'#table1 td'選擇器 –
控制檯中沒有任何東西? –
這個問題是由一個不能再現的問題引起的,或者是一個簡單的印刷錯誤**。 –