大神求帮助,新手刚入门
javascript吧
全部回复
仅看楼主
level 2
zzx555
楼主
想在输入框输入颜色英文,点击按钮后,背景颜色变为输入框输入的颜色,求大神帮忙
2020年11月03日 11点11分
1
level 12
丶影-奈斯
加上.value
str.value;
2020年11月03日 13点11分
2
zzx555
十分感谢
2020年11月07日 09点11分
level 12
丶影-奈斯
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title></title>
</head>
<body>
颜色:<input id="write" type="text" value="" />
<script>
var str = document.getElementById('write');
function color(str) {
document.body.style.backgroundColor = str.value;
}
</script>
<input type="button" onclick="color(str)" value="点击变色" />
</body>
</html>
2020年11月03日 13点11分
3
level 5
BYU_Styxer
.value
2020年11月07日 21点11分
5
1