
js中访问元素样式错误
在提供的代码中,你想要通过JavaScript访问
错误所在:
你的代码中的“style”属性存在拼写错误,正确写法是“style”。此外,在新式JavaScript中,“onclink”事件监听也已弃用,应使用“onclick”。
更正后的代码:
立即学习“Java免费学习笔记(深入)”;
box1.style.width = "300px"; box1.style.height = "300px"; box1.style.backgroundColor = "yellow";
正确写法:
将这段代码替换为更正后的代码:
box1.style.width = "300px"; box1.style.height = "300px"; box1.style.backgroundColor = "yellow";
修改后的代码示例:










