如何检查 $(this)
是 div
、ul
还是 blockquote
?
例如:
if ($(this) is a div) {
alert('its a div!');
} else {
alert('its not a div! some other stuff');
}
最佳答案
像这样:
if(this.tagName == 'DIV') {
alert("It's a div!");
} else {
alert("It's not a div! [some other stuff]");
}
关于javascript - 检查元素是否为 div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6518802/