HTML DOM Meter optimum 屬性
HTML DOM Meter 的 optimum 屬性返回/設定一個數字,該數字對應於 <meter> 元素的 optimum 屬性。將其與 high、low、min 和 max 屬性結合使用,可獲得更好的效果。
注意:不要將 <meter> 用作進度條,而只能將其用作儀表。
以下是語法
返回 optimum 屬性的值
meterElementObject.optimum
設定 optimum 屬性的值
meterElementObject.optimum = number
讓我們看一個 Meter optimum 屬性的示例 -
示例
<!DOCTYPE html>
<html>
<head>
<title>Meter optimum</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-optimum</legend>
<label for="paulaLifeSource">Paula's Health Risk: </label>
<meter id="paulaLifeSource" max="100" min="0" high="80" optimum="75" low="70" value="85"> </meter>
<input type="button" onclick="lifeSource()" value="Rectify Optimum level">
<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.optimum;
paulaLifeSource.optimum = 85;
divDisplay.textContent = 'Optimum level changed to '+paulaLifeSource.optimum+' from '+Immunity;
}
</script>
</body>
</html>輸出
點選“糾正最佳水平”按鈕之前 -

點選“糾正最佳水平”按鈕之後 -

廣告
資料結構
網路
RDBMS
作業系統
Java
iOS
HTML
CSS
Android
Python
C 程式設計
C++
C#
MongoDB
MySQL
Javascript
PHP