判断HTML元素类型


Warning: array_rand(): Array is empty in /srv/htdocs/wp-content/plugins/easy-random-quotes/kl-easyrandomquotes.php on line 268

不用jquery

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

使用jquery

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

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

===

Leave a Reply

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