js judges whether a class attribute exists to prompt information

I made a verification prompt today. It is necessary to judge whether the attribute el-button–primary exists in the class attribute.

The problem is as follows:
insert image description here

var primary;
$('.card-no').each(function (item,index) {
    
    
   primary = $(this).find('button').attr("class");
 });

if (primary.indexOf("el-button--primary") > -1) {
    
    
	console.log("已存在")
} else {
    
    
	console.log("不存在")
}

Guess you like

Origin blog.csdn.net/li22356/article/details/126282426