html 在没有jquery的情况下在javascript中处理事件的方法。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了html 在没有jquery的情况下在javascript中处理事件的方法。相关的知识,希望对你有一定的参考价值。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Multi-page template</title>
</head>
<body>
<h2 id="display-val">This is a header.</h2>
<input type="range" name="slider" id="sliderWeight" value="60" min="0" max="100">
<script>
// event name is user, not with 'on'.
document.getElementById('sliderWeight').addEventListener("change", function(){
document.getElementById('display-val').innerHTML = 'The value is ' + document.getElementById('sliderWeight').value;
})
document.getElementById('sliderWeight').onclick = function(e) {
console.log(e);
}
</script>
</body>
</html>
以上是关于html 在没有jquery的情况下在javascript中处理事件的方法。的主要内容,如果未能解决你的问题,请参考以下文章