jquery-table切换

来源:互联网 发布:防网络诈骗 编辑:程序博客网 时间:2024/06/05 23:56
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
span{
float: left;
width: 50px;
height: 30px;
background-color: yellow;
text-align: center;
}
.show{
width: 200px;
height: 150px;
background-color: gray;
color: white;
text-align: center;
line-height: 150px;
}
.hidden{
display: none;
}
</style>
</head>
<body>
  <div>
  <span>1</span>
  <span>2</span>
  <span>3</span>
  <span>4</span>
  </div>
  <div class="show">第一块</div>
  <div class="show hidden">第二块</div>
  <div class="show hidden">第三块</div>
  <div class="show hidden">第四块</div>
</body>


<script  src="js/jquery-3.2.1.min.js" ></script>
<script type="text/javascript">
$('span').on('click',function(){
$('span').css({'backgroundColor':'yellow'});
$('.show').css({'display':'none'});
$(this).css({'backgroundColor':'red'});
//$(this).css({'backgroundColor':'cyan'}).silbings().css({'':''});
// eq索引
        $('.show').eq($(this).index()).css({'display':'block'});
});
</script>
</html>
原创粉丝点击