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

You can use Regular Expression or split the class name.

$(".etape").click(function(){
   var classes = $.grep(this.className.split(" "), function(v, i){
       return v.indexOf('btn') === 0;
   }).join();
});

http://jsfiddle.net/LQPh6/

Leave a Comment