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

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

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

          <bdo id='cYSqd'></bdo><ul id='cYSqd'></ul>

        CSS/JQuery 悬停只影响悬停元素而不影响父元素

        CSS/JQuery Hover Affect Only Hovered Element and Not Parent(CSS/JQuery 悬停只影响悬停元素而不影响父元素)

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

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

        • <tfoot id='DS6Fg'></tfoot>
            1. <legend id='DS6Fg'><style id='DS6Fg'><dir id='DS6Fg'><q id='DS6Fg'></q></dir></style></legend>
                <bdo id='DS6Fg'></bdo><ul id='DS6Fg'></ul>

                    <tbody id='DS6Fg'></tbody>
                  本文介绍了CSS/JQuery 悬停只影响悬停元素而不影响父元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我有一个嵌套项目列表,每个项目都有自己的编辑链接.

                  I have a list of nested items, each which has it's own edit link.

                  <ul>
                  <li>Coffee</li>
                  <li>
                      Fruits <a href="#" class="editLink">Edit</a>
                      <ul>
                          <li>Banana <a href="#" class="editLink">Edit</a></li>
                          <li>Orange <a href="#" class="editLink">Edit</a></li>
                          <li>
                              Apple <a href="#" class="editLink">Edit</a>
                              <ul>
                                  <li>Fuji <a href="#" class="editLink">Edit</a></li>
                                  <li>Red Delicious <a href="#" class="editLink">Edit</a></li>
                                  <li>Golden <a href="#" class="editLink">Edit</a></li>
                              </ul>
                          </li>
                      </ul>
                  </li>
                  <li>
                      Drinks <a href="#" class="editLink">Edit</a>
                      <ul>
                          <li>Coke <a href="#" class="editLink">Edit</a></li>
                          <li>Pepsi <a href="#" class="editLink">Edit</a></li>
                      </ul>
                  </li>
                  <li>Something <a href="#" class="editLink">Edit</a></li>
                  </ul>
                  

                  我只希望在将鼠标悬停在列表元素上时显示编辑链接.目前,当我将鼠标悬停在子元素上时,父元素也会受到影响.

                  I only want the edit link to display when one hovers over list element. Currently when I hover on a child element, the parent is affected as well.

                  $('li').hover(
                      function(){
                          $(this).find('.editLink').show();
                      },
                      function(){
                          $(this).find('.editLink').hide();   
                      }
                  );
                  

                  我有以下 CSS 使编辑链接最初隐藏

                  I have the following CSS to make the edit link hidden initially

                  .editLink{
                      display:none;
                  }
                  

                  如何使只有悬停的元素显示编辑链接而不显示其他元素?似乎隐藏部分很好,但显示部分会影响所有嵌套的父母.以下是实际示例:http://jsfiddle.net/D7yWm/

                  How do I make it so that only the hovered element has the edit link show and not the others? Seems like the hide part is fine but the show part affects all the nested parents. Here is the sample in action: http://jsfiddle.net/D7yWm/

                  推荐答案

                  试试这个.它使用直接子选择器(http://jsfiddle.net/D7yWm/4/):

                  Give this a try. It uses the direct child selector (http://jsfiddle.net/D7yWm/4/):

                  $(document).ready(function(){
                      $('li').hover(
                          function(ev){
                              var li = $(this);
                              li.parents('li').find('>.editLink').hide();
                              if ( ! li.find('li > .editLink:visible').length ) {
                                  li.find('>.editLink').show();
                              }
                          },
                          function(){
                              var li = $(this);
                              li.find('>.editLink').hide();
                              li.parents('li:first').find('>.editLink').show();
                          }
                      );
                  });
                  

                  如果您希望它仅本地化为文本,则必须将文本包装在 <span> 或其他东西中,然后改用它.

                  If you want it localized to just the text, you're going to have to wrap the text in a <span> or something and use that instead.

                  ul {
                      list-style-position: inside;
                  }
                  

                  如果这对您不起作用,您可能需要考虑另一种添加项目符号的方法.或者以此为起点来解决剩下的问题……

                  And if that doesn't work for you, you may have to look at a different way of adding the bullets. Or use this as a starting point for figuring the rest out...

                  这篇关于CSS/JQuery 悬停只影响悬停元素而不影响父元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文档推荐

                  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
                  ExecJS::ProgramError: SyntaxError: Reserved word quot;functionquot;(ExecJS::ProgramError: SyntaxError: 保留字“function)
                  Infinite scroll and will_paginate appending the #39;next page#39; of items multiple times(无限滚动和 will_paginate 多次附加项目的“下一页)
                  What is cleanest way to turn Array of JQuery Promises into a JQuery Promise of an Array?(将 JQuery Promise 数组转换为数组的 JQuery Promise 的最简洁方法是什么?)
                  Scale background image to fit ie8 window(缩放背景图像以适合 ie8 窗口)
                  How to onclick-trigger a non-native jQuery plugin#39;s action?(如何点击触发非本地 jQuery 插件的操作?)
                    • <bdo id='JwE4p'></bdo><ul id='JwE4p'></ul>

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

                          <tbody id='JwE4p'></tbody>

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

                          1. <legend id='JwE4p'><style id='JwE4p'><dir id='JwE4p'><q id='JwE4p'></q></dir></style></legend>

                          2. <tfoot id='JwE4p'></tfoot>