当前位置: 首页>>编程示例 >>用法及示例精选 >>正文


HTML DOM Progress value属性用法及代码示例

HTML DOM 中的 Progress value 属性用于设置或返回 <progress> 元素的值。 value 属性用于使用进度条指定已完成的任务。

用法

它返回一个值属性。

progressObject.value

它设置 value 属性。



progressObject.value = number

属性值:它包含一个数值,表示进度条的已完成任务的状态。

返回值:它返回一个字符串值,该值指定进度条的已完成任务的状态。

例:下面的代码演示了如何显示和设置 value 属性。

HTML


<!DOCTYPE html>
<html>
  
<head>
    <title>
        HTML DOM Progress value Property
    </title>
</head>
  
<body>
    <center>
        <h1 style="color:green;">
            GeeksforGeeks
        </h1>
  
        <h2>DOM Progress value Property </h2>
  
        Downloading progress for a song:
        <progress id="GFG" value="30" max="100">
        </progress>
  
        <br><br>
        <button onclick="display()">
            Display value
        </button>
          
        <button onclick="setvalue()">
            setting value
        </button>
    </center>
  
    <script>
        function display() {
            var pr = document.getElementById("GFG").value;
            alert("The current status of progress Bar is:" + pr)
        }
        function setvalue() {
            var gf = document.getElementById("GFG").max = "50";
            alert("The value of the progress Bar is:" + gf);
        }
    </script>
</body>
  
</html>

输出:

支持的浏览器:

  • 谷歌浏览器
  • IE浏览器
  • Firefox
  • Opera
  • 苹果Safari



相关用法


注:本文由纯净天空筛选整理自ManasChhabra2大神的英文原创作品 HTML DOM Progress value Property。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。