HTML DOM 輸入 URL 表單屬性


HTML DOM Input URL 表單屬性是 輸入 URL 的封閉表單的引用。

語法

以下是語法 −

返回對錶單物件的引用

inputURLObject.form

示例

讓我們看一個 Input URL表單 屬性的例子 −

 直播演示

<!DOCTYPE html>
<html>
<head>
<title>Input URL form</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 id="Larry Page">
<fieldset>
<legend>URL-form</legend>
<label for="URLSelect">URL :
<input type="URL" id="URLSelect" size="25">
</label>
<input type="button" onclick="getform()" value="Get Co-founder">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   var inputURL = document.getElementById("URLSelect");
   function getform() {
      if(inputURL.value !== '')
         divDisplay.textContent = 'Co-founder: '+inputURL.form.id;
      else
         divDisplay.textContent = 'Please enter valid URL';
   }
</script>
</body>
</html>

輸出

這將產生以下輸出 −

點選 ‘獲取聯合創始人’ 按鈕之前 −

勾選了 ‘獲取聯合創始人’ 按鈕之後 −

更新日期: 30-Jul-2019

104 次瀏覽

啟動你的 職業生涯

完成課程即可取得認證

開始
廣告