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

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

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

        <tfoot id='PcvOO'></tfoot>

      1. 如何在悬停时更改文本框内容

        时间:2023-08-08

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

                • <tfoot id='JXdog'></tfoot>
                • 本文介绍了如何在悬停时更改文本框内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我无法弄清楚如何根据悬停在哪个链接上来更改文本框的内容.我可以让它与最接近 div 的任何一个一起工作,但其他链接似乎没有效果.但是,我不想在链接之间插入文本,也不想创建多个文本框.我的主要目标是让链接始终位于同一个位置,当您将鼠标悬停在它们上方时,下方的文本框将显示正确的内容.

                  I am having trouble trying to figure out how I can make a text box change content depending on what link is being hovered over. I can get it to work with which ever one is closest to the div but the other links seem to have no effect. I do not however want to have text being inserted in between the links nor do I want to create several text boxes. My main goal is to have the links always in the same place and when you hover over them a text box underneath will display the correct content.

                  这里有一些代码和一个 JSFiddle 我放在一起帮助更好地说明我的问题:JSFiddle

                  Here is some code and a JSFiddle I threw together to help better illustrate my question: JSFiddle

                  HTML:

                  <a class="one" href="#">one</a>
                  <a class="two" href="#">two</a>
                  <a class="three" href="#">three</a>
                  
                  <div class="element">hello</div>
                  

                  CSS:

                  .element {
                       display: none;
                  }
                  
                  a:hover + .element {
                       display: block;
                  }
                  

                  推荐答案

                  您需要以下 HTML 标记:

                  You need the follwing HTML mark-up:

                  <a href="#" class="a-1">one</a>
                  <a href="#"class="a-2">two</a>
                  <a href="#"class="a-3">three</a>
                  
                  <div class="element-1">hello one</div>
                  <div class="element-2">hello two</div>
                  <div class="element-3">hello three</div>
                  

                  然后应用以下 CSS:

                  and then apply the following CSS:

                  .element-1, .element-2, .element-3{
                       display: none;
                  }
                  .a-1:hover  ~ .element-1 {
                       display: block;
                  }
                  .a-2:hover  ~ .element-2{
                       display: block;
                  }
                  .a-3:hover  ~ .element-3 {
                       display: block;
                  }
                  

                  查看演示:http://jsfiddle.net/audetwebdesign/p7WUu/

                  CSS 略有重复,但可以正常工作,不需要 JavaScript.

                  The CSS is slightly repetitive but it works and no JavaScript required.

                  需要兄弟组合符 (~) 来挑选兄弟元素,请参阅参考.

                  The sibling combinator (~) is needed to pick out sibling elements, see reference.

                  参考:http://www.w3.org/TR/selectors/#兄弟组合器

                  这篇关于如何在悬停时更改文本框内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:由于文本框 onblur 事件中的警报框导致按钮单击事 下一篇:如何在普通的 html 文本框中自动换行?

                  相关文章

                  最新文章

                  • <bdo id='BGiFy'></bdo><ul id='BGiFy'></ul>

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

                  <legend id='BGiFy'><style id='BGiFy'><dir id='BGiFy'><q id='BGiFy'></q></dir></style></legend>
                    <tfoot id='BGiFy'></tfoot>

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