jquery get values for all of the same class label

Typically only jQuery always returns a value of the first class of tag. But we tend to need all the values ​​of a class tag, so:

var btn = $('.btn').val();//只能获得这个类标签的第一个值

//获得一组值
var btns = new Array();
$(".btn").each(function(){
    btns[key] = $(this).val();
    //  或者 btns[key] = $(value).val();
})

 

Guess you like

Origin blog.csdn.net/sinat_38439143/article/details/83617441