Today, according to the jquery manual to learn about the use of selectors, ready to try to write a user registration verification, did not expect to start a very small problem to me stumped!
The new person inevitably encounters very small detail problem, this article only for pasted:
Test part of the code is as follows:
Copy Code code as follows:
<script type= "Text/javascript" src= "Jquery.1.11.0.min.js" ></script>
<script type= "Text/javascript" >
function CheckUser () {//check user name functions
Alert ("OK"); Test...
}
$ (document). Ready (function () {
$ (": Text:first"). blur (function () {//When loss of focus triggers the event
/** here is where I have been tossing for a long time. Of course what I want to get is the user registration element, so I use
* As on the selector, the result is not! Check the code and find there is no error at all! What's the problem?
* The use of selector is problematic? I changed the #id selector, sure enough ok! but theoretically such a selector is certainly no problem!
* I also use $ (": Input:text"), Wrong! $ (": Input:eq (0)"); Error! Sister's! Where exactly is the problem?
* Now, hand a cheap, put: text and: First of a space accidentally deleted, a run, ni, ran up! Just try it again.
* Several selectors, full ok! After many tests, the following experience is obtained:
* When using a combination selector with internal relationships, no spaces can be added between them! $ (": Text:first)" Error! $ (": Text:first)
**/Right! When you use a combination selector for a hierarchical relationship, there are spaces between them
CheckUser ();
});
</script>
<body>
<form>
<fieldset>
<legend> Registration Page </legend>
User name <input type= "text" > <br>
Password <input type= "password" ><span> <br>
Verify password <input type= "password" > <br>
Email<input type= "text" ><span> <br>
<input type= "Submit" value= "registered" >
</fieldset>
</form>
</body>