鼠标一点 文字消失 的有关问题
鼠标一点 文字消失 的问题
请问大大们,如果鼠标一点文本框 文本框的默认值 就消失了,然后鼠标点别的地方,文本框又会自动显示默认值,这种效果该怎么做?
我上网搜了很多,用javascript写的,或者是onclick,onblur之类的我都试过,如果是纯html是可以用,但是写在php里面就一点作用都没有!这很奇怪啊!为什么?
代码如下:
- JScript code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/--><script language="JavaScript" type="text/javascript"> function addListener(element,e,fn){ if(element.addEventListener){ element.addEventListener(e,fn,false); } else { element.attachEvent("on" + e,fn); } } var txt_oldPsw = document.getElementById("txt_oldPsw"); addListener(txt_oldPsw,"click",function(){txt_oldPsw.value = "";}) addListener(txt_oldPsw,"blur",function(){txt_oldPsw.value = "old Password";}) var txt_newPsw = document.getElementById("txt_newPsw"); addListener(txt_newPsw,"click",function(){txt_newPsw.value = "";}) addListener(txt_newPsw,"blur",function(){txt_newPsw.value = "new Password";}) var txt_reenter = document.getElementById("txt_reenter"); addListener(txt_reenter,"click",function(){txt_reenter.value = "";}) addListener(txt_reenter,"blur",function(){txt_reenter.value = "re-enter new password";})</script>
- PHP code
<!--Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->echo "<tr><td><input class="txt_style" id="txt_oldPsw" style="font-size:10.5pt; color:#6b6b6b" type="text" name="txt_oldPsw" value="old password"></td></tr>"; echo "<tr><td><input class="txt_style" id="txt_newPsw" style="font-size:10.5pt; color:#6b6b6b" type="text" name="txt_newPsw" value="new password"></td></tr>"; echo "<tr><td><input class="txt_style" id="txt_reenter" style="font-size:10.5pt; color:#6b6b6b" type="text" name="txt_reenter" value="re-enter new password"></td></tr>"; echo "<tr><td><input class="btn_active" type="submit" name="$btn_active_define" value="$btn_active_text"></td></tr>";
谢谢了!
------解决方案--------------------
你的 js 要放在 php 之后!
即 txt_newPsw = document.getElementById("txt_newPsw");
需要在 ------解决方案--------------------
JS在清空文本框默认值的时候,顺带把type="text"改成type="password"不就得了。document.getElementById("inputId").type="password";

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

IntelTXT is a hardware-assisted security technology launched by Intel. It can ensure the integrity and security of the server during startup by establishing a protected space between the CPU and BIOS. The full name of TXT is TrustedExecutionTechnology, which is Trusted Execution Technology. Simply put, TXT is a security technology that provides hardware-level protection to ensure that the server has not been modified by malicious programs or unauthorized software when it is started. this one

Methods for converting html to txt include using a text editor, using online conversion tools, and using Python programming. Detailed introduction: 1. To open an HTML file, you can use any text editor, such as Notepad, Sublime Text, etc. To select the content of the entire HTML file, you can press the Ctrl+A shortcut key or drag the mouse to select and copy the selection. The content can be copied by pressing the Ctrl+C shortcut or through the copy option in the right-click menu, opening a new TXT file, using the same text editor, etc.

chm is converted to txt by using online conversion tools, using browser plug-ins, using command line tools and using third-party software. Detailed introduction: 1. Use the online conversion tool, just upload the CHM file, select the TXT format, and then download the converted TXT file; 2. Use the browser plug-in, after installing the plug-in, just open the CHM file in the browser, and then Click the plug-in button to convert CHM files into TXT format; 3. Use command line tools, etc.

Pandas is a data analysis tool for Python, especially suitable for cleaning, processing and analyzing data. During the data analysis process, we often need to read data files in various formats, such as Txt files. However, some problems will be encountered during the specific operation. This article will introduce answers to common questions about reading txt files with pandas and provide corresponding code examples. Question 1: How to read txt file? txt files can be read using the read_csv() function of pandas. This is because

php提交表单通过后,弹出的对话框怎样在当前页弹出php提交表单通过后,弹出的对话框怎样在当前页弹出而不是在空白页弹出?想实现这样的效果:而不是空白页弹出:------解决方案--------------------如果你的验证用PHP在后端,那么就用Ajax;仅供参考:HTML code

The steps to convert chm to txt are to prepare tools and environment, open CHM file, export TXT file, edit TXT file, save and close TXT file. Detailed introduction: 1. Prepare tools and environment, prepare CHM reader, text editor and operating system; 2. Open the CHM file and use the CHM reader to open the CHM file you want to convert. In the reader, you can select the file you want to convert. Pages or chapters, some readers may allow the conversion of multiple pages, while others only allow the conversion of a single page; 3. Export TXT files, etc.

txt is not a word document. txt is a text format that mainly stores text information, that is, text information; while Word document is a format of electronic documents (the suffix is doc or docx). How to convert txt to word document: 1. Select the txt file on the desktop, right-click "Rename"; 2. Modify the suffix name format to "doc"; 3. Click "Yes" in the pop-up window box; 4. Double-click Open the file, select the appropriate encoding in the pop-up window, and click "OK" in the lower right corner.

Sometimes we need to change the file suffix to protect the file for some work or confidentiality reasons, but some friends may not know how to change the txt suffix in win7, especially when the file extension is not displayed. In fact, we only need to unhide it. , let’s take a look at the specific methods. Win7txt suffix change tutorial 1. First open "Computer" 2. Click "Organization" in the upper left corner and select "Folder and Search Options" 3. Enter the "View" tab. 4. Uncheck "Hide extensions for known folder types" 5. After saving, we can change the txt suffix.
