判断HTML元素类型

Posted on Posted in Misc

不用jquery

if(el.tagName == 'SELECT'){
    //
}

使用jquery

$el.is('select')
$el.is('SELECT')
$el.get(0).tagName == 'SELECT'

使用元素原生属性tagName测试时,类型名要用大写。也就是tagName属性输出的是大写的标签类型名。

===
[erq]

Leave a Reply

Your email address will not be published. Required fields are marked *