JQuery selectors in small problems of newcomers inevitably encountered

  • 2020-03-30 02:28:42
  • OfStack

Today, according to the jQuery manual to learn, understand the use of the selector, ready to try to write a user registration verification, did not expect to have not started a small problem stumped me!

New appointees inevitably encounter small details, in this article only for self-encouragement:

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 username function
alert("OK"); //Test...
} 

$(document).ready(function(){ 

$(":text :first").blur(function (){ //Something that triggers when you lose focus

  Right!!! When using hierarchical combination selectors, there are Spaces between them  
checkUser(); 

}); 

</script> 

</head> 
<body> 

<form> 
<fieldset> 
<legend> The sign-up page </legend> 
 The 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> 
</html> 

Related articles: