gpt4 book ai didi

javascript - 在 if 语句中使用 Javascript 对象变量

转载 作者:行者123 更新时间:2023-11-27 22:36:53 25 4
gpt4 key购买 nike

我正在使用 javascript 来显示购物篮的信息。我知道如何提取数据并从中创建元素,但我需要使用 if 语句的变量之一,并且不确定如何操作。

如果这是 true: "isPunchOut": false, 那么我想用 jQuery 来定位它,并执行类似 $(".button"的操作).remove();

我该怎么做?

var retailerData = {
"del": {
"zip": "",
"city": ""
},
"user": {
"country": "",
"phone": "",
"nbrOrders": 0,
"isPunchOut": false,
"name": "",
"salesPerson": "",
"customerNo": "",
"email": ""
},
"order": {
"shippingSum": 0.0,
"shippingFormatSum": "\u20AC0",
"orderno": "0",
"orderFormatSum": "\u20AC130",
"voucher": "",
"orderFormatVat": "\u20AC27,30",
"currencySymbol": "\u20AC",
"currency": "EUR",
"orderVat": 27.3,
"orderSum": 130.0,
"items": [{
"imageURI": "\/imgr\/8c82380c-65f5-43aa-83ad-fae1215b5b39\/70\/70",
"qtyAvail": 7,
"price": 130.0,
"qty": 1,
"artno": "D630-T7100-GE-REF",
"vat": 27.3,
"formatVat": "\u20AC27,30",
"id": "52307",
"label": "D630 C2D-T7100/2GB/80GB/DVD/14"/NO COA WLAN",
"category": "Computers - Notebooks",
"formatPrice": "\u20AC130",
"manufacturer": "Dell"
}]
}
}

最佳答案

您可以看一下下面的JS代码作为引用:

var isPunchOut = retailerData["user"]["isPunchOut"];
if(isPunchOut === false)
$(".button").remove();

关于javascript - 在 if 语句中使用 Javascript 对象变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39032773/

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