<html>
<body>
搜索: <input type="search" id="mySearch" maxlength="30">
<p>点击按钮显示搜索字段的 maxlength 属性值。</p>
<button onclick="myFunction()">点我</button>
<p id="demo"></p>
<script>
function myFunction() {
var x = document.getElementById("mySearch").maxLength;
document.getElementById("demo").innerHTML=x;
}
</script>
</body>
</html>