gpt4 book ai didi

javascript - Noob javascript 1行解释

转载 作者:行者123 更新时间:2023-11-29 16:13:42 26 4
gpt4 key购买 nike

下面这行是做什么的?

(flag)?flag=false:flag=true;

在这段代码中:

  var flag = true;
function resize() {
if(flag) {
document.getElementById("centerimg").style.width = "150%";
document.getElementById("centerimg").style.height = "150%";
document.getElementById("center").style.left = 120+"px";
} else {
document.getElementById("centerimg").style.width = "100%";
document.getElementById("centerimg").style.height = "100%";
document.getElementById("center").style.left = 190.5+"px";
}
(flag)?flag=false:flag=true;
}

最佳答案

这和你写的一样:

if(flag){
flag = false;
}else{
flag = true;
}

关于javascript - Noob javascript 1行解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20922877/

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