<html>
<head><script type="text/javascript" src="jquery-1.7.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("tr").click(function(){
$(this).toggleClass("red");
});
});
</script>
</head>
<style>
.red {
background-color: red;
}
</style>
<body>
<table border="2" style='width:80%;height:30px'>
<tr>
<th>Month</th>
</tr>
<tr>
<th>Month</th>
</tr>
</table>
</body>
</html>
这篇博客展示了如何使用jQuery实现元素点击后改变颜色,再次点击时恢复原颜色的功能,提供了一个实用的代码案例。
3253

被折叠的 条评论
为什么被折叠?



