<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8"/>
<title>checkbox radio</title>
<script type="text/javascript" src="jquery-1.8.3.js">
</script>
<style>
div
{
height:10px;
width:10px;
background:red;
border :1px solid black;
}
.swap
{ background:yellow;
}
</style>
<script type="text/javascript">
$(function () {
$("div").each(function () {
$(this).click(function () {
$(this).css("background-color", "yellow");
alert("diyigexuanzhong");
});
});
});
</script>
</head>
<body>
<div id = "div"></div>
<div id = "div1"></div>
<div id = "div2"></div>
</body>
</html>
遍历每一个div。
当点击div的时候背景颜色会发生变化,由原来的红色变成黄色!
498

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



