gpt4 book ai didi

javascript - 是否可以创建一个变量但将其隐藏在 javascript 中?

转载 作者:行者123 更新时间:2023-11-28 04:43:23 28 4
gpt4 key购买 nike

我正在尝试创建一个脚本,用户可以在其中更改文本框背景的颜色并添加边框,我有背景工作和边框脚本工作但我似乎无法弄清楚如何使添加边框可选,这是脚本:

function newColor(){
var colorChange = prompt('What color would you like the background?');
var borderConfirm = confirm('Would you like a border?');
var borderSize = prompt('Would you like your border to be thin, medium, or thick?');
var borderColor = prompt('What color would you like your border?');
if(borderConfirm == true){
borderSize;
borderColor;
}
else{
alert('No border will be added');
}
document.getElementById('backgroundcolorchange').style.backgroundColor = colorChange;
document.getElementById('backgroundcolorchange').style.borderWidth = borderSize;
document.getElementById('backgroundcolorchange').style.borderColor = borderColor;

console.log(borderSize);
console.log(borderColor);
}
#backgroundcolorchange{
background-color:#900;
width:auto;
height:auto;
position:absolute;
border:.001px #900 solid;
}
<div id="backgroundcolorchange" onClick="newColor()">
<p id="test" style="margin:0;"> Your Text Will Go Here! </p>
</div>

后来才给出选项,不知道是我的变量有问题还是我的语句有问题。请帮忙。

最佳答案

    function newColor(){
var colorChange = prompt('What color would you like the background?');
var borderConfirm = confirm('Would you like a border?');
if(borderConfirm == true){
var borderSize = prompt('Would you like your border to be thin, medium, or thick?');
var borderColor = prompt('What color would you like your border?');
}

关于javascript - 是否可以创建一个变量但将其隐藏在 javascript 中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41089671/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com