jquery Selector Small problem (rookie encounter) _jquery

Source: Internet
Author: User
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>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.