How to get elements of specific class starting with a given string?

后端 未结 11 850
面向向阳花
面向向阳花 2021-02-03 21:19

I have a list of elements that have multiple classes, for example:


         


        
11条回答
  •  执念已碎
    2021-02-03 21:44

    You can also try:

    $(".etape").click(function () {
        var theClass = $(this).attr("class").match(/btn[\w-]*\b/);
        console.log(theClass); 
    });
    

    Uses match instead of grep...

提交回复
热议问题