How can I see if an element as a class that consists of only numbers and return its value, ignoring other classes?
如何将元素视为仅包含数字的类并返回其值,而忽略其他类?
<div class="some_identifier some_other_class 1548"></div>
So running it on the above HTML
would return 1548
因此,在上面的HTML上运行它将返回1548
2 个解决方案
#2
0
Try with:
var div = $('<div class="some_identifier some_other_class 1548"></div>');
div.attr('class').match(/\S\d+\S/);
#1
#2
0
Try with:
var div = $('<div class="some_identifier some_other_class 1548"></div>');
div.attr('class').match(/\S\d+\S/);