HTML DOM Input URL size 属性
Input URL size 属性获取/设置 input URL 的 size 属性。如果未定义此属性,它会返回“20”。
语法
以下是语法 −
- 返回size 属性
inputURLObject.size
- 为 size 属性设置一个数字
inputURLObject.size = number
示例
我们来看一个Input URL size 属性的示例 −
<!DOCTYPE html>
<html>
<head>
<title>Input URL size</title>
<style>
form {
width:70%;
margin: 0 auto;
text-align: center;
}
* {
padding: 2px;
margin:5px;
}
input[type="button"] {
border-radius: 10px;
}
</style>
</head>
<body>
<form>
<fieldset>
<legend>URL-size</legend>
<label for="URLSelect">URL:
<input type="url" id="URLSelect" size="10">
</label><br>
<input type="button" onclick="increaseVisibility()" value="Increase Visibility">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
var divDisplay = document.getElementById("divDisplay");
var inputURL = document.getElementById("URLSelect");
function increaseVisibility() {
inputURL.size = 30;
divDisplay.textContent = 'Visibility Increased to '+inputURL.size;
}
</script>
</body>
</html>输出
这将产生以下输出 −
点击“增加可见性”按钮之前 −

点击“增加可见性”按钮之后 −

广告
数据结构
网络
RDBMS
操作系统
Java
iOS
HTML
CSS
Android
Python
C 编程
C++
C#
MongoDB
MySQL
Javascript
PHP