<html>
<head>
<meta charset="utf-8" />
<script src="jquery.min.js" ></script>
<script >
$(function() {
var tab = $("#tab");
var span = tab.find("span");
var div = tab.find("div");
$.each(span, function(i, val) {
val.onclick = function() {
$.each(div, function(divI, divVal) {
if(i == divI) {
divVal.style.display = "block";
} else {
divVal.style.display = "none";
}
});
}
});
$("#tab div").hide();
$("#tab div").eq(1).show();
});
</script>
</head>
<body>
<div id="tab">
<span>教育</span>
<span>娱乐</span>
<span>汽车</span>
<div>教育的内容</div>
<div>娱乐的内容</div>
<div>汽车的内容</div>
</div>
</body>
<head>
<meta charset="utf-8" />
<script src="jquery.min.js" ></script>
<script >
$(function() {
var tab = $("#tab");
var span = tab.find("span");
var div = tab.find("div");
$.each(span, function(i, val) {
val.onclick = function() {
$.each(div, function(divI, divVal) {
if(i == divI) {
divVal.style.display = "block";
} else {
divVal.style.display = "none";
}
});
}
});
$("#tab div").hide();
$("#tab div").eq(1).show();
});
</script>
</head>
<body>
<div id="tab">
<span>教育</span>
<span>娱乐</span>
<span>汽车</span>
<div>教育的内容</div>
<div>娱乐的内容</div>
<div>汽车的内容</div>
</div>
</body>
</html>