小白在线求助
javascript吧
全部回复
仅看楼主
level 3
🐱🐶 楼主
为什么点击按钮没有效果,是缺少什么语句嘛
2022年03月14日 14点03分 1
level 3
你后面需要加px,不加px就是等于把宽=200,识别不出来
2022年03月15日 04点03分 6
是myvideo.style.width=200+'px'
2022年03月15日 04点03分
@樱花树的爱- 或者myvideo.width+=20也可以
2022年03月15日 04点03分
谢谢大佬,问题解决了
2022年03月15日 06点03分
level 2
第1,你onclick后面的函数调用写的就不对,其次,我想你是通过js动态改变css样式,可以去百度一下
2022年03月29日 03点03分 7
level 1
<div style="text-align:center">
<button onclick="b()"> 放大</button>
<button onclick="c()"> 缩小</button>
<button onclick="d()"> 正常</button>
<br />
<video id="video1" width="420" style="border:2px solid red"></video>
</div>
<br />
<br />
<br />
<script>
var video = document.getElementById("video1");
function b() {
video.setAttribute("width", Number(video.getAttribute("width")) + 10);
}
function c() {
video.setAttribute("width", Number(video.getAttribute("width")) - 10);
}
function d() {
video.setAttribute("width", "420");
}
</script>
2022年04月27日 01点04分 8
1