开发者

Select div that ends with a class

开发者 https://www.devze.com 2023-03-28 07:16 出处:网络
Like this one: <div clas开发者_如何学运维s=\"abc foo-something\"> How can I select div that has a class ending in -something?@Einacio commented correct that$(\"div[class$=\'-something\']\") wi

Like this one:

<div clas开发者_如何学运维s="abc foo-something">

How can I select div that has a class ending in -something?


@Einacio commented correct that $("div[class$='-something']") will not work for <div class="foo-something abc">. To select and this case you can add a second selector, with the following result:

$("div[class$='-something'],div[class*='-something ']")

This will select and classes that ending with -something and a space follows.

Check this for more info.

0

精彩评论

暂无评论...
验证码 换一张
取 消