Check if element is a div

前端 未结 11 1336
南方客
南方客 2021-02-02 04:44

How do I check if $(this) is a div, ul or blockquote?

For example:

if ($(this) is a div) {
  alert(\'         


        
11条回答
  •  不思量自难忘°
    2021-02-02 05:20

    if(this.tagName.toLowerCase() == "div"){
        //it's a div
    } else {
        //it's not a div
    }
    

    edit: while I was writing, a lot of answers were given, sorry for doublure

提交回复
热议问题