什么类型的DOM元素? [英] What type of DOM Element?

查看:121
本文介绍了什么类型的DOM元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

e.g. if i have this:
<div id='mydiv'>whatever</div>

然后在jQuery中说,我怎么能发现id为mydiv的dom元素是一个DIV或一些其他元素类型。

then let say in jQuery, how can I find out that the dom element with id "mydiv" is a DIV or is some other element type.

e.g. 
$('#mydiv').????  ?


推荐答案

var type = $('#mydiv')[0].tagName

alert(type);
//displays "DIV"

这篇关于什么类型的DOM元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆