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>