I have a class .object
which has an attribute called level
. I want to get a list of all the different values of level
on the page so I can select the highest one.
If I do something like:
$(".object").attr("level")
... will that get me a list of values that are the values of the level attribute? I suspect not, but then how do you do something like that?
Note: I don't want to select an HTML object for manipulation as is more common, rather I want to select values of the attribute.
EDIT: In order to get the highest "level" I have done this, but it doesn't seem to work. I will try the other suggested method now.
var highLevel=0;
$.each(".object[level]", function(i, value) {
if (value>highLevel) {
highLevel=value;
}
});
alert(highLevel);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…