You can use document.getElementById('divId').className.split(/s+/);
to get you an array of class names.
Then you can iterate and find the one you want.
var classList = document.getElementById('divId').className.split(/s+/);
for (var i = 0; i < classList.length; i++) {
if (classList[i] === 'someClass') {
//do something
}
}
jQuery does not really help you here...
var classList = $('#divId').attr('class').split(/s+/);
$.each(classList, function(index, item) {
if (item === 'someClass') {
//do something
}
});
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…