How to choose a div that has a class ending in -something ? ...">

Select a div that ends with a class

Like this:

<div class="abc foo-something">

How to choose a div that has a class ending in -something ?

+7
source share
1 answer

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

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

This will select both classes ending in -something, and a space follows.

Open this one for more information.

+18
source

Source: https://habr.com/ru/post/894945/


All Articles