The difference between the two classes of jQuery selectors with or without spaces

The difference between the two classes of jQuery selectors with or without spaces

1. No spaces.
$(".class1.class2")What is obtained is a label object that contains both "class1" and "class2" in the class attribute

2. If there is a space,
$(".class1 class2")all the sub-label objects whose class attribute is "class2" in the (first) tag whose class attribute is class1 are obtained

Example:

// 满足 $(".class1.class2")
<div class = "class1 class2"></div>

// 满足 $(".class1 class2") 
<div class = "class1">
	<div calss = "class2"><div>
</div>

Guess you like

Origin blog.csdn.net/weixin_40307206/article/details/109090655