HTML DOM 輸入提交型別屬性


HTML DOM 輸入提交型別屬性與具有 type=”submit” 的輸入元素相關聯。它總是會為輸入提交元素返回提交。

語法

以下是對提交型別屬性的語法 −

submitObject.type

示例

我們來看一個提交型別屬性的示例 −

<!DOCTYPE html>
<html>
<body>
<h1>Input range type Property</h1>
<form>
VOLUME <input type="range" id="RANGE1" name="VOL">
</form>
<p>Get the above input element type by clicking the below button</p>
<button type="button" onclick="rangeType()">GET Type</button>
<p id="Sample"></p>
<script>
   function rangeType() {
      var P=document.getElementById("RANGE1").type;
      document.getElementById("Sample").innerHTML = "The type for the input field is: "+P ;
   }
</script>
</body>
</html>

輸出

這將生成以下輸出 −

點選“獲取型別”按鈕 −

更新於: 19-Feb-2021

88 次瀏覽

開啟你的 職業生涯

透過完成課程獲得認證

Get Started
廣告
© . All rights reserved.