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

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

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


         


        
11条回答
  •  独厮守ぢ
    2021-02-03 21:27

    Try this,

    if($(selector).attr("class").lastIndexOf("classToStartFrom") == 0)
       return "this selector class name starts with 'classToStartFrom'";
    else
       return "this selector class name doesn't start with 'classToStartFrom'";
    

    The code is not tested.

提交回复
热议问题