0

我有一个剑道 ui 控件,可以在运行时创建以下 html 语法

<input id=​"ItemSearch" name=​"ItemSearch" style=​"width:​115px;​" type=​"text">​

如何使用 javascript 将 maxlength HTML5 属性应用于它

当我使用以下内容时,我得到了Cannot call method 'prop' of undefined

 $('#ItemSearch').input.prop("maxlength", 2);
4

1 回答 1

5

您不需要.input,因为$('#ItemSearch')已经选择了该元素。尝试这个:

$('#ItemSearch').prop("maxlength", 2);
于 2013-11-01T11:23:10.970 回答