HTML DOM 輸入搜尋 size 屬性
HTML DOM 輸入搜尋 size 屬性用於設定或返回輸入搜尋欄位的 size 屬性值。它用於定義以字元為單位的搜尋欄位寬度。預設寬度為 20 個字元。
語法
- 的語法如下:
設定 Search 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>輸出
這將產生以下輸出 -

單擊 CHANGE 按鈕 -

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
JavaScript
PHP