我禁用基于一个复选框形式禁止在表单中输入的每个领域,裹在一张桌子选择和jQuery的
我无法加入禁用属性。
这里是我走到这一步: HTML:
<table id="shipInfoTable">
<tr>
<td>Name:</td>
<td><input type="text" name="name" /></td>
</tr>
...
</table>
的Javascript选择/属性操作(jQuery的):
$("#shipInfoTable tbody tr td input").each(function(index, item){
item.attr("disabled", true);
});
Chrome浏览器开发控制台错误: Uncaught TypeError: Object #<an HTMLInputElement> has no method 'attr'
当我警告item
在.each()
之内它会提醒[object HTMLInputElement]
不太确定如何正确选择输入元素。我究竟做错了什么?
请注意:在当前版本的jQuery中,这被改为'.prop(“disabled”,true)'。我很确定'attr'没有做的事是有意的。 – Kobi 2013-02-20 10:52:10