首先; HTML代码示例:

<div class"grap1"> some conetent</div>
<div class"grap2"> some conetent</div>
<div class"grap3"> some conetent</div>
<div class"blabla">some content></div>

现在,我想选择该类包含“废话”字样的div是类名(因此在本例中为前三个div)。我该如何实现?

这不起作用:http://api.jquery.com/attribute-contains-word-selector/

最佳答案

使用attribute contains selector:

$('div[class*="grap"]')

关于jquery - 例如,选择类包含 “grap”(o其他指定的单词)的div(或其他元素),我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7378382/

10-10 21:51