js改变增加减小字号大小
程序员文章站
2022-05-06 11:38:00
...
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<script type="text/javascript">
window.onload = function(){
var bts = document.getElementById('btns');
var btx = document.getElementById('btnx');
var txt = document.getElementById('txt');
// console.log(txt.innerHTML);
var sz = 16;
bts.onclick = function(){
sz = sz + 1;
console.log(sz);
txt.style.fontSize = sz + 'px';
}
btx.onclick = function(){
sz = sz - 1;
console.log(sz);
txt.style.fontSize = sz + 'px';
}
}
</script>
</head>
<body>
<button type="button" id="btns">字号加</button>
<button type="button" id="btnx">字号减</button>
<p id="txt">*万岁!</p>
</body>
</html>
上一篇: js计算357整除的数
下一篇: JavaScript事件的冒泡