1. [attribute] Usage
Definition: Match elements containing the given attribute
$("div[id]").addClass("highlight"); //Find all divs with ID attributes Element
2. [attribute=value] Usage
Definition: Match elements
where the given attribute is a specific value Copy code The code is as follows:
$("input[name='basketball']").attr("checked",true ); //The input element whose name attribute value is basketball is selected
3. [attribute!=value] usage
definition: matching the given attribute is not included Elements with a specific value
$("input[name !='basketball']").attr("checked",true); //The name attribute value is not selected for the input element of basketball
//This selector is equivalent to: not([attr=value]) To match elements that contain a specific attribute but are not equal to a specific value, use [attr]:not([attr=value])
$("input:not(input[name='basketball'])").attr ("checked",true);
4. [attribute^=value] Usage
Definition: Match elements where the given attribute starts with a certain value
$("input[name^='foot'] ").attr("checked",true); //Find all input elements whose name starts with 'foot'
5. [attribute$=value] Usage
Definition: Matches elements whose given attributes end with certain values
$("input[name$='ball']").attr("checked",true); //Find all input elements whose name ends with 'ball'
6. [attribute*=value] Usage
Definition: Match the given attribute by elements containing certain values
$("input[name*='sket']").attr("checked",true); //Find all Name input element containing 'sket'
7. [selector1][selector2][selectorN] Usage
Definition: Composite attribute selector, which needs to satisfy multiple requirements at the same time Use
$("input[id][name $='ball']").attr("checked",true); //Find all attributes containing id and whose name attribute ends with ball