使用jQuery查找元素的类型 [英] finding the type of an element using jQuery

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

问题描述

在jQuery中,如果我有一个元素的引用,如何确定它是哪种元素,例如输入或下拉列表?有什么办法找出来的吗?

In jQuery, if I have a reference to an element, how can I determine what kind of element it is, for example, an input or an dropdown? Is there any way to find out?

重复:

如何进行确定jQuery中匹配元素的元素类型?

推荐答案

如果元素是输入,则以下内容将返回true:

The following will return true if the element is an input:

$("#elementId").is("input") 

或者您可以使用以下命令获取标签的名称:

or you can use the following to get the name of the tag:

$("#elementId").get(0).tagName

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

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