Introduction to the use of wildcards in jQuery selectors


1. The selector (1) wildcard:


$("input[id^='code']");//All input tags that start with code for the id attribute
$("input[id$='code']");//All input tags whose id attribute ends with code
$("input[id*='code']");//The id attribute contains all the input tags for the code

(2) selection by index


$("tbody tr:even"); //Select all tr tags with an even index
$("tbody tr:odd"); //Select all tr tags with an odd index

(3) get the input number of the node at the next level of the jqueryObj


jqueryObj.children("input").length;

(4) get all < under the child node of the tag class as main; A> The label


$(".main > a");

(5) select next to the label


jqueryObj.next("div");//Gets a div immediately after the queryobj tag, and nextAll gets all

2. The filter


//not
$("#code input:not([id^='code'])");//The id is the code tag that does not contain all input tags whose id begins with code

3. The event


//Handles keyboard operations on text boxes
jqueryObj.keyup(function(event){
var keyCode = event.which;//Gets the key value of the currently pressed keyboard, and the return key is 13
}

4. Utility functions


$('#someField').val($.trim($('#someField').val()));//Eliminate whitespace, syntax: $.trim(value)