jquery how to select all the class elements start with “text-”?

后端 未结 6 697
夕颜
夕颜 2020-11-30 02:18

I have got some classes

.text-1
.text-2
.text-3

I want to select them all, how to do that? Thanks for the help

6条回答
  •  执笔经年
    2020-11-30 02:58

    You don't necessarily need to specify asterisk *, you can do this too:

    $('[class^="text-"]')
    

    Notice the addition of - after text something you are looking for.

    Check out the jQuery starts with selector for more information.

提交回复
热议问题