HTML high 屬性


HTML high 屬性用於指示量表的最高值。將其與量表的 max、min 和 low 屬性一起使用可獲得更好的結果。

讓我們來看看一個 Meter 高度 屬性的示例 −

示例

 即時演示

<!DOCTYPE html>
<html>
<head>
<title>Meter high</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>Meter-high</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="70" value="85"></meter>
<input type="button" onclick="lifeSource()" value="Medi Kit">
<div id="divDisplay"></div>
</fieldset>
</form>
<script>
   var divDisplay = document.getElementById("divDisplay");
   divDisplay.textContent = 'Life Source at '+paulaLifeSource.value;
   function lifeSource(effect){
      var paulaLifeSource = document.getElementById("paulaLifeSource");
      var Immunity = paulaLifeSource.high;
      paulaLifeSource.high = 90;
      divDisplay.textContent = 'Immunity increased to '+paulaLifeSource.high+' from '+Immunity;
   }
</script>
</body>
</html>

這將產生以下輸出 −

1) 在點選‘Medi Kit’ 按鈕之前 −

2) 在點選‘Medi Kit’ 按鈕之後 −

更新於: 19-09-2019

106 次瀏覽

Kickstart Your 職業

完成課程獲得認證

開始
廣告
© . All rights reserved.