我正在努力实现这一目标:http: //jsfiddle.net/BcFVv/2/
这是我的本地代码,但它不能正常工作:
我错过了什么吗?错误地实现了库?错误地包装了函数?
<!--- CSS --->
<style type="text/css">
.mydivhide {
display: none
}
</style>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
</head>
<body>
<!--- JQUERY --->
<script type="text/javascript">
$(document).ready(function() {
$("#buttons a").click(function() {
var id = $(this).attr("id");
$("#pages div").css("display", "none");
$("#pages div#" + id + "").css("display", "block");
});
});
</script>
<div id="buttons">
<a href="#" id="1" class="mybutton myred">Div 1</a>
<a href="#" id="2" class="mybutton myblue">Div 2</a>
<a href="#" id="3" class="mybutton myblue">Div 3</a>
</div>
<div id="pages">
<div id="1" class="mydivshow">1111</div>
<div id="2" class="mydivhide">2222</div>
<div id="3" class="mydivhide">3333</div>
</div>