javascript – jQuery选择器中的Tilde

前端之家收集整理的这篇文章主要介绍了javascript – jQuery选择器中的Tilde前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我对 Javascript中波形符的功能的理解是它执行按位运算(即1变为0,反之亦然; 1000变为0111).但是,我最近开始研究一个现有的项目,我的前任已经包含了很多这样的代码

var iValuation = $('div[class~="iValuation"]');

任何人都可以告诉我在这个例子中代字号的目的是什么?我之前没遇到它,也没能在网上找到任何参考.

解决方法

那不是JavaScript运算符.它出现在一个字符串中.

由于该字符串被传递给jQuery函数,并且它看起来不像HTML,它是一个selector.

特别是attribute selectors之一:

Represents an element with the att attribute whose value is a whitespace-separated list of words,one of which is exactly “val”. If “val” contains whitespace,it will never represent anything (since the words are separated by spaces). Also if “val” is the empty string,it will never represent anything.

猜你在找的jQuery相关文章