
“鼠标放过”要用“onmouseover”这个
“onmousemove”是鼠标移动的
class的效果你已经定义了吧?(那就不用说了)
“this.class='red1' ”,语法错了,所以没有效果
应该用:this.className='red1'
这个“className”的“N”一定要大写,否则也没有效果
例:
<tr onmouseover="this.className='red1'" onmouseout="this.className='恢复的Class名称'" class="red" >
先在样式表中写好点击的效果,然后在通过JS来添加删除这个样式就可以了,具体看下面这个例子<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="../jquery-1.9.1.min.js"></script>
<script type="text/javascript">
$(function(){
$('table tr').click(function(){
$('table tr').removeClass('on')
$(this).addClass('on')
})
})
</script>
<style type="text/css">
*{
padding: 0
margin: 0
}
tr.on td{
background-color: #e5e5e5
}
</style>
</head>
<body>
<table width="100%">
<tr class="on">
<td>sdfas</td>
</tr>
<tr>
<td>sdfas</td>
</tr>
<tr>
<td>sdfas</td>
</tr>
<tr>
<td>sdfas</td>
</tr>
</table>
</body>
</html>
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)