SOURCE

console 命令行工具 X clear

                    
>
console
/**
 *tab选项卡
 *
 * @param {$el} tabItem 切换的top页对象
 * @param {arr} cls 为数组对象[0当前导航的类,1控制tab显示的类(可不传)]
 * @param {str} type 接收字符串,触发类型'mouseenter'||'click',可不传 默认点击事件
 */
$.fn.Uitab = function(tabItem, cls, type) {
  var ui = this;
  type = type || 'click';
  var clsLen = cls.length;
  ui.on(type, function(e) {
    var index = $(this).index();
    if (clsLen >= 2) {
      ui.removeClass(cls[0]).eq(index).addClass(cls[0]);
      tabItem.removeClass(cls[1]).eq(index).addClass(cls[1]);
    } else {
      ui.removeClass(cls[0]).eq(index).addClass(cls[0]);
      tabItem.hide().eq(index).show();
    }
    e.stopPropagation();
  });
  if (clsLen < 2) {
 	 ui.eq(0).trigger(type);
  }
};

$('.ul-tab li').Uitab($('.m-item'), ['tab'], 'mouseenter');
<div class="container">
  <ul class="ul-tab">
    <li>
      <a href="">
        tab1
      </a>
    </li>
    <li  class="tab">
      <a href="">
        tab2
      </a>
    </li>
    <li>
      <a href="">
        tab3
      </a>
    </li>
    <li>
      <a href="">
        tab4
      </a>
    </li>
  </ul>
  <div class="ul-tab-item">
    <div class="m-item show">
      内容1
    </div>
    <div class="m-item">
      内容2
    </div>
    <div class="m-item">
      内容3
    </div>
    <div class="m-item">
      内容4
    </div>
  </div>
</div>
 * {
   margin: 0;
   padding: 0;
 }
 
 ul {
   list-style: none;
 }
 
 a {
   text-decoration: none;
 }
 
 .container {
   position: relative;
   margin: 50px;
 }
 
 .ul-tab {
   overflow: hidden;
 }
 
 li {
   position: relative;
   float: left;
   width: 80px;
   height: 60px;
   margin-right: 10px;
   border-top-right-radius: 8px;
   border-top-left-radius: 8px;
   border: 1px solid #ccc;
   border-bottom: none;
 }
 
 .ul-tab-item {
   width: 100%;
   height: 100px;
   /* background-color: green; */
   border-top: 1px solid #ccc;
   position: absolute;
   top: 60px;
 }
 
 .m-item {
   display: none;
 }
 /* 点击时的li样式 */
 
 li.tab {
   background-color: #fff;
   z-index: 5;
 }
 /*  .show {
   display: block;
 } */

本项目引用的自定义外部资源