Small issues with selector in jQuery

Source: Internet
Author: User

The jQuery selector problem encountered during user registration verification. The following is a record. If you encounter a similar situation, refer

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: <script type = "text/javascript" src = "jquery.1.11.0.min. js "> </script> <script type =" text/javascript "> function checkUser () {// check the user name's function alert (" OK "); // test...} $ (Document ). ready (function () {$ (": text: first "). blur (function () {// events triggered when the focus is lost/** this is where I 've been tossing for a long time. Of course, I want to get the user registration element, so I use the * above selector, and the result will 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! Make sure you try the just-then-several selectors. All are OK! After multiple tests, the following experience is 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>

Related Article

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.