HTML DOM Input Search size 属性
htmlweb developmentfront end technology更新于 2024/5/28 12:28:17
HTML DOM Input Search size 属性用于设置或返回输入搜索字段的 size 属性值。该属性用于定义搜索字段的字符宽度。默认宽度为 20 个字符。
语法
以下是语法 −
设置搜索 size 属性 −
searchObject.size = number
此处,number 表示搜索字段的字符宽度。默认宽度为 20 个字符。
示例
让我们看一个 Input Search size 属性的示例 −
<!DOCTYPE html>
<html>
<body>
<h1>Input search size property</h1>
<form>
FRUITS: <input type="search" id="SEARCH1" name="fruits">
</form>
<p>Change the Search field width by clicking the below button</p>
<button onclick="changeSize()">CHANGE</button>
<p id="Sample">
<script>
function changeSize() {
document.getElementById("SEARCH1").size+=20;
var s=document.getElementById("SEARCH1").size;
document.getElementById("Sample").innerHTML="The search field width is now "+ s;
}
</script>
</body>
</html>
输出
这将产生以下输出 −

点击"更改"按钮 −

相关文章
有用资源
html 参考教程 - 该教程包含有关 html 的更多信息:https://www.cainiaomax.com/html/

