HTML DOM Meter min 屬性


Meter low 屬性返回/設定一個 <meter> 元素的 min 屬性所對應的數字。連同高、最和最屬性一起使用可獲得較好的結果。

語法

以下是語法 −

  • 返回 min 屬性的值
meterElementObject.min
  • 設定 min 屬性值
meterElementObject.min = number

示例

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

 即時演示

<!DOCTYPE html>
<html>
<head>
<title>Meter min</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-min</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" low="60" value="60" optimum="40"></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+'/'+paulaLifeSource.max;
   function lifeSource(){
      var paulaLifeSource = document.getElementById("paulaLifeSource");
      var Immunity = paulaLifeSource.min;
      paulaLifeSource.min = 20;
      divDisplay.textContent = 'Permenant Damage to '+paulaLifeSource.min+' from '+Immunity;
   }
</script>
</body>
</html>

輸出

這將產生以下輸出 −

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

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

更新於: 2019 年 8 月 1 日

90 次瀏覽

開啟你的 職業生涯

完成課程認證,開拓你的職業道路

開始學習
廣告
© . All rights reserved.