<tfoot id='pakmk'></tfoot>

      <i id='pakmk'><tr id='pakmk'><dt id='pakmk'><q id='pakmk'><span id='pakmk'><b id='pakmk'><form id='pakmk'><ins id='pakmk'></ins><ul id='pakmk'></ul><sub id='pakmk'></sub></form><legend id='pakmk'></legend><bdo id='pakmk'><pre id='pakmk'><center id='pakmk'></center></pre></bdo></b><th id='pakmk'></th></span></q></dt></tr></i><div id='pakmk'><tfoot id='pakmk'></tfoot><dl id='pakmk'><fieldset id='pakmk'></fieldset></dl></div>
      • <bdo id='pakmk'></bdo><ul id='pakmk'></ul>
    1. <small id='pakmk'></small><noframes id='pakmk'>

        <legend id='pakmk'><style id='pakmk'><dir id='pakmk'><q id='pakmk'></q></dir></style></legend>

        jQuery:从另一个元素触发悬停事件

        jQuery: trigger a hover event from another element(jQuery:从另一个元素触发悬停事件)
        • <bdo id='lGhxB'></bdo><ul id='lGhxB'></ul>
            <tbody id='lGhxB'></tbody>
          <tfoot id='lGhxB'></tfoot>

          <legend id='lGhxB'><style id='lGhxB'><dir id='lGhxB'><q id='lGhxB'></q></dir></style></legend>

                <small id='lGhxB'></small><noframes id='lGhxB'>

                  <i id='lGhxB'><tr id='lGhxB'><dt id='lGhxB'><q id='lGhxB'><span id='lGhxB'><b id='lGhxB'><form id='lGhxB'><ins id='lGhxB'></ins><ul id='lGhxB'></ul><sub id='lGhxB'></sub></form><legend id='lGhxB'></legend><bdo id='lGhxB'><pre id='lGhxB'><center id='lGhxB'></center></pre></bdo></b><th id='lGhxB'></th></span></q></dt></tr></i><div id='lGhxB'><tfoot id='lGhxB'></tfoot><dl id='lGhxB'><fieldset id='lGhxB'></fieldset></dl></div>

                  本文介绍了jQuery:从另一个元素触发悬停事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  当您将鼠标悬停在一个 <div> 上时,我希望页面的单独部分上的 <a> 也可以悬停"在其上.

                  <div class="initiator"></div>

                  <a class="receiver href="#">触摸 div 我会悬停!</a></div>

                  我试过这个 jQuery,但它不会触发 <a> 的悬停 CSS.

                  $(".initiator").hover(function(){$(".receiver").hover();console.log("div 被悬停");});

                  解决方案

                  试试这个:

                  $('.initiator').on('mouseenter mouseleave', function(e) {$('.receiver').trigger(e.type);})

                  它将为接收者应用与发起者为 mouseenter 和 mouseleave 接收相同的触发器.请注意:

                  .hover(over, out)

                  只是以下的高级变体:

                  .on('mouseenter', over).on('mouseleave', out)

                  因此在绑定和触发鼠标事件时,使用这些信息可以更加精确.

                  如评论中所述,您还可以使用:

                  $('.initiator').hover(function(e) {$('.receiver').trigger(e.type);})

                  这里还有很多内容要阅读:http://api.jquery.com/hover/

                  When you hover over one <div>, I want an <a> on a separate part of the page to be "hovered" on also.

                  <div class="initiator">
                  </div>
                  <div>
                     <a class="receiver href="#">Touch the div and I get hovered!</a>
                  </div>
                  

                  I've tried this jQuery, but it doesn't trigger the <a>'s hover CSS.

                  $(".initiator").hover(function(){
                     $(".receiver").hover();
                     console.log("div was hovered");
                  });
                  

                  解决方案

                  Try this:

                  $('.initiator').on('mouseenter mouseleave', function(e) {
                      $('.receiver').trigger(e.type);
                  })
                  

                  It will apply the same triggers for the receiver as the initiator receives for both mouseenter and mouseleave. Note that:

                  .hover(over, out) 
                  

                  is just a high-level variant of:

                  .on('mouseenter', over).on('mouseleave', out)
                  

                  so using that information you can be more precise when binding and triggering mouse events.

                  As noted in the comment, you can also use:

                  $('.initiator').hover(function(e) {
                      $('.receiver').trigger(e.type);
                  })
                  

                  There are lots more to read here: http://api.jquery.com/hover/

                  这篇关于jQuery:从另一个元素触发悬停事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  在开发JS过程中,会经常遇到两个小数相运算的情况,但是运算结果却与预期不同,调试一下发现计算结果竟然有那么长一串尾巴。如下图所示: 产生原因: JavaScript对小数运算会先转成二进制,运算完毕再转回十进制,过程中会有丢失,不过不是所有的小数间运算会
                  append() 方法在被选元素的结尾(仍然在内部)插入指定内容。 语法: $(selector).append( content ) var creatPrintList = function(data){ var innerHtml = ""; for(var i =0;i data.length;i++){ innerHtml +="li class='contentLi'"; innerHtml +="a href
                  问题描述: 在javascript中引用js代码,然后导致反斜杠丢失,发现字符串中的所有\信息丢失。比如在js中引用input type=text onkeyup=value=value.replace(/[^\d]/g,) ,结果导致正则表达式中的\丢失。 问题原因: 该字符串含有\,javascript对字符串进行了转
                  Rails/Javascript: How to inject rails variables into (very) simple javascript(Rails/Javascript:如何将 rails 变量注入(非常)简单的 javascript)
                  quot;Each child in an array should have a unique key propquot; only on first time render of page(“数组中的每个孩子都应该有一个唯一的 key prop仅在第一次呈现页面时)
                  CoffeeScript always returns in anonymous function(CoffeeScript 总是以匿名函数返回)
                  <tfoot id='vJQyW'></tfoot>
                  <i id='vJQyW'><tr id='vJQyW'><dt id='vJQyW'><q id='vJQyW'><span id='vJQyW'><b id='vJQyW'><form id='vJQyW'><ins id='vJQyW'></ins><ul id='vJQyW'></ul><sub id='vJQyW'></sub></form><legend id='vJQyW'></legend><bdo id='vJQyW'><pre id='vJQyW'><center id='vJQyW'></center></pre></bdo></b><th id='vJQyW'></th></span></q></dt></tr></i><div id='vJQyW'><tfoot id='vJQyW'></tfoot><dl id='vJQyW'><fieldset id='vJQyW'></fieldset></dl></div>

                    <tbody id='vJQyW'></tbody>
                • <legend id='vJQyW'><style id='vJQyW'><dir id='vJQyW'><q id='vJQyW'></q></dir></style></legend>
                      <bdo id='vJQyW'></bdo><ul id='vJQyW'></ul>
                        • <small id='vJQyW'></small><noframes id='vJQyW'>