如何在使用jQuery的事件中确定HTML输入元素类型? [英] How do I determine an HTML input element type upon an event using jQuery?
本文介绍了如何在使用jQuery的事件中确定HTML输入元素类型?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
以下示例代码:
$(document).ready(function(){
$( :input)。blur(function(){
alert(输入类型为:); //这将如何显示??????
})
} );
如何确定这是一个输入,选择,文本等?
这不是一个现实世界的例子,但应该足以解决这个问题。
pre> $(本).attr( 类型);
查看jQuery的选择器/属性文档以获得更多信息。
Given the following sample code:
$(document).ready(function(){
$(":input").blur(function(){
alert("The input type is:" ); //How would this look??????
})
});
How can I detemine whether this is an input, select, text, etc?
This is not a real-world example but should suffice for the purposes of this question
解决方案
$(this).attr("type");
See jQuery's Selectors/Attribute documentation for additional information.
这篇关于如何在使用jQuery的事件中确定HTML输入元素类型?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文