Javascript 价格销售没有定义。但是,确实如此
我发现错误Javascript 价格销售没有定义。但是,确实如此,javascript,jquery,Javascript,Jquery,我发现错误PriceSelling未定义。但事实上,我知道它在页面上,因为它将它记录在控制台中。请帮忙!谢谢 $.get(window.location, function(data){ var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/; var PriceSelling = data.match(regex)[1]; console.lo
PriceSelling
未定义。但事实上,我知道它在页面上,因为它将它记录在控制台中。请帮忙!谢谢
$.get(window.location, function(data){
var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;
var PriceSelling = data.match(regex)[1];
console.log(PriceSelling);
});
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
if (get('bot') && get('expecting') && get('expecting') == PriceSelling) {
console.log("It's a go!");
document.getElementsByClassName('conf-buy-now btn-primary btn-medium PurchaseButton ')[0].click();
//document.getElementById('conf-confirm-btn').click();
};
$.get(窗口、位置、函数(数据){
var regex=/([\d,]+)/;
var PriceSelling=data.match(regex)[1];
控制台日志(价格销售);
});
函数get(名称){
if(name=(新的RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)).exec(location.search))
返回组件(名称[1]);
}
if(get('bot')&&get('expecting')&&get('expecting')==价格销售){
log(“开始了!”);
document.getElementsByClassName('conf-buy-now btn primary btn medium PurchaseButton')[0]。单击();
//document.getElementById('conf-confirm-btn')。单击();
};
它在传递给$的回调函数的作用域中定义。get
但它没有在全球范围内定义
你可以
var PriceSelling;
$.get(window.location, function(data){
var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;
PriceSelling = data.match(regex)[1];
console.log(PriceSelling);
});
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
if (get('bot') && get('expecting') && get('expecting') == PriceSelling) {
console.log("It's a go!");
document.getElementsByClassName('conf-buy-now btn-primary btn-medium PurchaseButton ')[0].click();
//document.getElementById('conf-confirm-btn').click();
}
PriceSelling未在您调用它的范围内定义。为什么它会记录它?它会记录,因为PriceSelling声明和您的console.log在同一范围内。
$.get(window.location, function(data){
var regex=/<span class="it " data-se="item-privatesale-price">([\d,]+)<\/span>/;
var PriceSelling = data.match(regex)[1];
console.log(PriceSelling);
function get(name){
if(name=(new RegExp('[?&]'+encodeURIComponent(name)+'=([^&]*)')).exec(location.search))
return decodeURIComponent(name[1]);
}
if (get('bot') && get('expecting') && get('expecting') == PriceSelling) {
console.log("It's a go!");
document.getElementsByClassName('conf-buy-now btn-primary btn-medium PurchaseButton ')[0].click();
//document.getElementById('conf-confirm-btn').click();
}
});