87,910
社区成员
发帖
与我相关
我的任务
分享
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript" src="jquery-1.3.2.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$("#each li").click(
function() {
$(this).css("background","#FF0000").siblings().css("background","#ffffff");
});
});
</script>
<style type="text/css">
</style>
</head>
<body>
<div id="each">
<ul>
<li>111111111111111111111111</li>
<li>222222222222222222222222</li>
<li>333333333333333333333333</li>
<li>444444444444444444444444</li>
<li>555555555555555555555555</li>
<li>666666666666666666666666</li>
<li>777777777777777777777777</li>
</ul>
</div>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="../rains.jquery.matrix/jquery.js"></script>
<style type="text/css">
.red {
background-color: red;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("span").click(function() {
$(this).toggleClass("red");
});
});
</script>
<p>
<span>A</span> , <span>B</span> and <span>C</span> , which you will click?
</p>
</body>
</html>
<html>
<head>
<script type="text/javascript" src="../rains.jquery.matrix/jquery.js"></script>
<style type="text/css">
.red {
background-color: red;
}
</style>
</head>
<body>
<script type="text/javascript">
$(document).ready(function() {
$("span").click(function() {
$(this).addClass("red");
});
});
</script>
<p>
<span>A</span> , <span>B</span> and <span>C</span> , which you will click?
</p>
</body>
</html>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Title</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.5.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).ready( function() {
$("#spans span").click( function() { $(this).css("background-color","red").siblings().css("background-color","white"); });
});
</script>
</head>
<body>
<div id="spans">
<span>span1</span><span>span2</span><span>span3</span>
</div>
</body>
</html>
<html>
<body>
</body>
<div>
<span>span1</span><span>span2</span><span>span3</span>
</div>
<script type="text/javascript">
var len = document.getElementsByTagName('span').length;
for( i = 0; i < len; i ++) {
document.getElementsByTagName('span')[i].onclick = function() {
for( j = 0; j < len; j ++) document.getElementsByTagName('span')[j].style.backgroundColor = 'white';
this.style.backgroundColor = 'red';
}
}
</script>
</html>