Today, I learned how to use the selector according to the jQuery manual. I am going to try to write a user registration verification. I didn't expect to start a very small problem that made me difficult!
It is inevitable that new users will encounter very small details. In this article, we will only encourage them:
The test code is as follows:
Copy codeThe Code is as follows:
<Script type = "text/javascript" src = "jquery.1.11.0.min. js"> </script>
<Script type = "text/javascript">
Function checkUser () {// check the function of the user name
Alert ("OK"); // test...
}
$ (Document). ready (function (){
$ (": Text: first"). blur (function () {// triggered when the focus is lost
/** This is where I have been tossing for a long time. Of course, I want to obtain the user registration element, so I use
* The above selector does not work at all! Check the code and find that there is no error at all! What is the problem?
* Is there a problem with selector usage? I used the # id selector. It's OK! However, in theory, this selector is certainly okay!
* I used $ (": input: text") Again. Error! $ (": Input: eq (0)"); error! Sister's! Where is the problem?
* At this moment, I accidentally deleted a space in text and: first, and ran it! Try again
* A few selectors, all OK! After multiple tests, the following experiences are obtained:
* When using a combination selector with an internal inclusion relationship, no space is allowed between them! $ (": Text: first)" error! $ (": Text: first)
**/Correct! When using the hierarchical link combination selector, there must be spaces between them.
CheckUser ();
});
</Script>
</Head>
<Body>
<Form>
<Fieldset>
<Legend> registration page </legend>
Username <input type = "text"> <br>
Password <input type = "password"> <span> <br>
Password verification <input type = "password"> <br>
Email <input type = "text"> <span> <br>
<Input type = "submit" value = "register">
</Fieldset>
</Form>
</Body>
</Html>