- <html>
- <head>
- <script type="text/javascript" src1="http://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
- <script type="text/javascript">
- $(function(){
- $('div').each(function(i) {
- $('div').eq(0).show().nextAll().hide();
- });
- $('span').click(function(){
- $(this).addClass('checked').siblings().removeClass();
- $("div").hide().eq($('span').index(this)).show().nextAll().CSS("display","none");
- });
- });
- </script>
- </head>
- <style type="text/css">
- .checked { background:red}
- .one,.two,.three { width:50px;height:22px;line-height:20px;border:1px red solid}
- </style>
- <body>
- <span class="one">one</span><span class="two">two</span><span class="three">three</span>
- <div class="">Hello</div>
- <div class="">World</div>
- <div class="">jquery</div>
- </body>
- </html>
- //该片段来自于http://www.codesnippet.cn/detail/130620134001.html
来源: http://www.codesnippet.cn/detail/130620134001.html