找到这个帖子: https://stackoverflow.com/questions/43524985/how-to-get-change-value-of-html5-progress-bar
<script>
document.addEventListener("DOMContentLoaded", function(event) {
/* DOM is ready, so we can query for its elements */
var dragonHealth = document.getElementById("health").value;
console.log(dragonHealth);
/*additional code for comment*/
document.querySelector('button').addEventListener("click", function(event){
document.getElementById("health").value += 5;
});
})
</script>
<progress id="health" value="60" max="100"></progress>
<button>change progress value</button>
按下按钮,进度条跑一格.
离线