方法:一
<input type="text" id="tb_Test" />
< input type="button" id="btn_Test" value="Button />
var type = document.getElementById("tb_Test").type;
if(type == "text"){
alert("it is input box.");
}
if(type == "button"){
alert("it is button.");
}
<input type="text" id="txt">
< select id="select"><option>1</option></select>
< script type="text/javascript">
var txt=document.getElementById("txt");
var select=document.getElementById("select");
alert(txt.type);
alert(select.type);
方法:二
<
input
id
=
"tt"
/>
<
select
id
=
"select1"
onchange
=
"chengSelect()"
>
<
option
value
=
"1"
>test </
option
>
<
option
value
=
"2"
>test1 </
option
>
<
option
value
=
"3"
>test2 </
option
>
</
select
>
<
script
>
var input = document.getElementById("tt");
var select1 = document.getElementById("select1");
alert(input.tagName);
alert(select1.tagName);
</
script
>
alert(obj.tagName);
if
(obj.tagName==
"INPUT"
){
alert(obj.type);
}
获取值:取select元素中当前选择的文本内容(而不是选项的值)
var tt=$("form select[name=selectName]").find('option:selected').text();
alert(tt);
把selectName换成你表单中的下拉框name值就行了
要是使用ID查询这样就行了
var tt=$("#selectId").find('option:selected').text();