可能重复:
How do I determine an HTML input element type upon an event using jQuery?如何获得输入对象的类型
我想输入对象的类型,但我送花儿给人有“不确定”。
这个代码是什么遗漏的?
var c = $("input[name=\'lastName\']");
c.val("test");
alert(c.type);
我的形式
<form action="formAction.jsp" method="post">
FirstName <input type="text" name="firstName" id="firstName"></input><br/>
LastName <input type="text" name="lastName"></input><br/>
Address <input type="text" name="address"></input><br/>
Tel <input type="text" name="tel"></input><br/>
Email <input type="text" name="email"></input><br/>
</form>
因为它已经是一个jQuery对象,所以不需要在'$()'中包装'c',而是''attr'的+1,这是问题的答案。 –