Computer >> คอมพิวเตอร์ >  >> การเขียนโปรแกรม >> HTML

HTML DOM เมตร คุณสมบัติขั้นต่ำ


คุณสมบัติ Meter low ส่งกลับ/ตั้งค่าตัวเลขที่สอดคล้องกับแอตทริบิวต์ min ของ องค์ประกอบ. ใช้สิ่งนี้กับแอตทริบิวต์สูง สูงสุด และต่ำเพื่อผลลัพธ์ที่ดีกว่า

ไวยากรณ์

ต่อไปนี้เป็นไวยากรณ์ -

  • คืนค่าของ นาที ทรัพย์สิน
meterElementObject.min
  • ค่าของ นาที ชุดคุณสมบัติ
meterElementObject.min = number

ตัวอย่าง

เรามาดูตัวอย่างสำหรับ มิเตอร์ขั้นต่ำ ทรัพย์สิน −

<!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' ปุ่ม −

HTML DOM เมตร คุณสมบัติขั้นต่ำ

หลังจากคลิก ‘Medi Kit’ ปุ่ม −

HTML DOM เมตร คุณสมบัติขั้นต่ำ