悬停时导航

时间:2017-11-11 01:12:12

标签: javascript jquery css menu

我想在“父母”之外的区域上空盘旋时删除“open”类。怎么办? 这是我的笔: https://codepen.io/anon/pen/aVJapG

我正试图让悬停的导航停止。

这是我的js:

    function hover(tab) {
  showAndHiddenOthers(tab.id);
}

function showAndHiddenOthers(id) {
  for (var i = 0, len = document.getElementsByTagName('li').length; i < len; i++) {
    if (id[id.length - 1] == i + 1) {

      document.getElementById('p' + (i + 1)).style.display = 'block';
      document.getElementById('tab' + (i + 1)).style.backgroundColor = '#3cf';
    } else {

      document.getElementById('p' + (i + 1)).style.display = 'none';
      document.getElementById('tab' + (i + 1)).style.backgroundColor = '#3c9';
    }
  }
}

0 个答案:

没有答案
相关问题