悬停左侧JQuery,如果没有点击项,设置值在他们所在的地方

Hover left JQuery, if there is not click on item, set values where they were

本文关键字:他们 设置 JQuery 如果没有 悬停      更新时间:2023-09-26

我有这个代码,我需要当没有一个项目点击和悬停结束时,参数返回他们所在的位置。例如边框和文本颜色。如果有人能帮助我,我会非常感激....

$(document).ready(function() { 
    $('#siteloader').load('empleados.jsp');
    $('ul#menu li a.active').css({"border-bottom": "4px solid"});
      $('ul#menu li a').click(function() {
          var page = $(this).attr('href');
          this.setAttribute("id", "lix");
          if (page !== 'index.jsp') {
              $('#siteloader').load(page + '.jsp');
              $('ul#menu li a').css({"color": "#000"});
              $(this).css({"color": "#ca4b00"});
              return false;
          }
          return true;
      });
      $('ul#menu li a').hover(function() {
          $('ul#menu li a').css({"color": "#000"});
          $('ul#menu li a').css({"border-bottom-style": "none"});
          $(this).css({"color": "#ca4b00"});
          $(this).css({"border-bottom": "4px solid"});
      }); 
});`

你可以使用mouselleft,它会起作用,类似的问题

$('ul#menu li a').mouseleave(function() {
    // hover end stuuf
});

为什么不在css中使用:hover呢?

<style>
ul#menu li a:hover {
border-bottom-style: none;
}
</style>

试试鼠标悬停和离开的格式:

$('ul#menu li a').hover(
    function() {
        //hover
    },
    function(e) {
       //leave
    }
);

Demo使用ToogleClass