Check if element is a div

前端 未结 11 1337
南方客
南方客 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:24

    Going through jQuery you can use $(this).is('div'):

    Check the current matched set of elements against a selector, element, or jQuery object and return true if at least one of these elements matches the given arguments.

提交回复
热议问题