Home  >  Article  >  Web Front-end  >  The specific implementation method of not writing value as the initial value of input_javascript skills

The specific implementation method of not writing value as the initial value of input_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:30:011174browse

1. Write with tag, position it on the input, and make it disappear when clicked and when the input is focused.

For example, making the most common initial value of input. In the past, I just wrote it in the value of input. But one day the developer said, this won't work, it will pass 7788% of the value... @The rest can only be understood but cannot be expressed in words. Therefore, I need to write the initial value separately, so I am stupid, so I write it with the tag, position it on the input, and make it disappear when clicked and when the input is focused.

Words that must be memorized. There are a lot of them on the Internet. If you just make them and use them without even looking at them, you will be the most stupid person in the world! ! My hands are still shaking as I type, and I really can’t forgive myself for such a tiny mistake. For a lazy and stupid person. Just put the correct words where you can think of them.

previousSibling finds the previous node.

nextSibling finds the next node.

html

Copy code The code is as follows:



js, pay attention to that long long long long word! ! ! ! ! If you spell it wrong again, it will be chopped off.
Copy code The code is as follows:

var CHECKON={
showHelpInfo:function(idTa ){
var pve=(idTa.previousSibling.nodeType==1)?idTa.previousSibling:idTa.previousSibling.previousSibling;
pve.style.display='none'
},
hide :function(classN,id2){
var idBox=document.getElementById(id2);
classN.style.display='none';
idBox.focus();
}
}

2. Use a background image to add a background image to the input, and make the image disappear when it is in focus.

3.html5 has the latest attribute, the placeholder attribute, which will automatically appear in the input and appear in gray. But it only disappears when input is entered. But HTML5, you know, IE8 does not support it.

There is another problem with the above, that is, the browser will remember the previously entered records. When the login page is opened again, the account and password will appear automatically. Of course it's a good thing. But, for the span tag positioning method set previously, ghosting will occur.

If you use a background image, it can basically be solved, but ie7 cannot.

Add the following code to the header to clear the previously cached login records:
Copy code The code is as follows:




Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn