<bdo id='RRGvM'></bdo><ul id='RRGvM'></ul>
  • <tfoot id='RRGvM'></tfoot>

    1. <small id='RRGvM'></small><noframes id='RRGvM'>

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

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

        HTML/CSS 用灰色的文本制作一个文本框,当我点击

        时间:2023-08-07

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

          <small id='7gaf2'></small><noframes id='7gaf2'>

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

              <tbody id='7gaf2'></tbody>
            • <bdo id='7gaf2'></bdo><ul id='7gaf2'></ul>
                <tfoot id='7gaf2'></tfoot>
                  本文介绍了HTML/CSS 用灰色的文本制作一个文本框,当我点击输入信息时消失,如何?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  如何制作一个内容为灰色的文本框,当我点击它输入文本时,灰色部分消失并允许我输入所需的文本?

                  How do I make a textbox that has a grayed out content, and when I click on it to enter text, the grayed out portion, it disappears and allows me to enter the desired text?

                  例子:

                  名字"文本框.名字"字样在文本框中显示为灰色,当我单击时,这些字词会消失,我会在其中写下我的名字.

                  A "First Name" text box. The words "First Name" are inside the text box grayed out, when I click, those words disappear and I write my name in it.

                  推荐答案

                  这个答案说明了 HTML5 之前的方法.请查看 Psytronic 的答案,了解使用 placeholder 属性的现代解决方案.

                  This answer illustrates a pre-HTML5 approach. Please take a look at Psytronic's answer for a modern solution using the placeholder attribute.

                  HTML:

                  <input type="text" name="firstname" title="First Name" style="color:#888;" 
                      value="First Name" onfocus="inputFocus(this)" onblur="inputBlur(this)" />
                  

                  JavaScript:

                  JavaScript:

                  function inputFocus(i) {
                      if (i.value == i.defaultValue) { i.value = ""; i.style.color = "#000"; }
                  }
                  function inputBlur(i) {
                      if (i.value == "") { i.value = i.defaultValue; i.style.color = "#888"; }
                  }
                  

                  这篇关于HTML/CSS 用灰色的文本制作一个文本框,当我点击输入信息时消失,如何?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:只允许在输入文本框中输入数字 下一篇:StackOverflow 的“标签"文本框自动完成是如何工

                  相关文章

                  最新文章

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

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

                        <bdo id='kHZsk'></bdo><ul id='kHZsk'></ul>
                      <legend id='kHZsk'><style id='kHZsk'><dir id='kHZsk'><q id='kHZsk'></q></dir></style></legend>
                    2. <tfoot id='kHZsk'></tfoot>