我有一张带有背景图片和两张<td>
的桌子。
我基本上想在悬停其中一个td时更改整个表背景图像。有什么方法可以做到吗?
答案 0 :(得分:0)
使用jQuery:
$( function() {
$('#OneOfTheTD').click( function() {
$(this).parent("table").toggleClass("class-with-other-background");
} );
} );
答案 1 :(得分:0)
HTML:
<table id="ch">
<tr>
<td>hsadkj</td>
<td>asdy</td>
<td>jghsdk</td>
</tr>
<tr>
<td onmouseover="chan()">dsjh</td>
<td>ksahd</td>
<td>kldfjh</td>
</tr>
</table>
JS:
function chan()
{
document.getElementById("ch").style.backgroundImage="url";
}