可以从元素中删除maxlength属性吗?我认为将其设置为0会起作用,但似乎FF4会阻止输入任何内容。http://jsfiddle.net/hMc4y/
我听说将它设置为-1确实会触发错误,并且removeAttribute也不起作用。
发布于 2011-03-18 15:54:38
使用"removeAttribute('maxLength')“应该可以很好地工作;也许令人惊讶的是,属性名称必须是"maxLength”,并且必须是大写的"L“。考虑一下:
<form name="f">
<input name="t" type="text" maxlength="5"/>
</form>
<script type="text/javascript">
var t = document.f.t;
alert(t.maxLength); // 5
t.removeAttribute('maxLength');
alert(t.maxLength); // 524288 (on Chrome/10.0.648.134)
</script>发布于 2011-03-18 15:45:13
我在火狐3.5和Chrome上都能使用removeAttribute。
https://stackoverflow.com/questions/5349265
复制相似问题