HTML 代码:
<input type="file" name="efile" id="efile" data-cat="electronics" style="width:100%" class="alertme">
<input type="file" name="dfile" id="dfile" data-cat="Decoratives" style="width:100%" class="alertme">
<input type="file" name="kfile" id="kfile" data-cat="kitchen" style="width:100%" class="">
<input type="file" name="hdfile" id="hdfile" data-cat="Home" style="width:100%" class="">
<input type="file" name="ffile" id="ffile" style="width:100%" data-cat="Furnitures" class="alertme">
如何获取存在类alertme的data-cat属性值?感谢您阅读我的问题。我的英语很弱,所以如果我犯了任何语法或拼写错误,请向我道歉。
最佳答案
这是实现此目的的代码:
$(".alertme").each(function(){
// Here you can fill your array or whatever you want..
$(this).attr("data-cat");
});
关于javascript - 如何从元素类中获取数据值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40486067/