Function implementation:
When users enter text, if they can highlight the text box that is being entered, it will be more humane, and then use jquery to implement it.
Implementation principle:
After the document is loaded (ready), add the focus and blur events for input, and make additions and deletions to the styles.
code example:
Copy Code code as follows:
<style type= "Text/css" >
. redback{}{
Color:white;
background:red;
BORDER:2PX solid black;
}
</style>
<script language= "javascript" src= "Jquery-1.1.4.js" type= "Text/javascript" ></script>
<script language= "JavaScript" >
$ (document). Ready (function () {
$ (' input '). focus (function () {
$ (this). addclass (' Redback ');
Alert ("Hello");
});
$ (' input '). blur (function () {
$ (this). Removeclass (' Redback ');
});
});
</script>
<body>
<input type= "text" value= "Hello,shanzhu" id= "MyText" >
<input type= "text" value= "Hello,shanzhu" id= "MyText2" >
<input type= "text" value= "Hello,shanzhu" id= "MyText3" >
<input type= "text" value= "Hello,shanzhu" id= "MYTEXT4" >
<input type= "text" value= "Hello,shanzhu" id= "MYTEXT5" >
<input type= "text" value= "Hello,shanzhu" id= "MyText6" >
</body>
Depending on the requirements of the test, after alert, position the cursor at the specified location. After the lookup found: Focus properties can be easily done.
Alert ("Name cannot be empty!") ");
Locate the desired focus by ID
$ ("#name"). focus ();
That is, when the output is prompted, the focus returns to the entry. Similar can also be added to the corresponding style. If you can highlight the text box you are typing, it will be more humane, and use jquery to do the following.
After the document is loaded (ready), add the focus and blur events for input, and make additions and deletions to the styles.