Jquery 更改不同函数中的href值
假设我有以下html和jquery脚本: //html脚本Jquery 更改不同函数中的href值,jquery,Jquery,假设我有以下html和jquery脚本: //html脚本 <a href="http://tr.abc.com/?id=qwe&media=34567" class="getitnow" id="prod123"></a> <a href="http://tr.abc.com/?id=qwe&media=34567" class="getitnow" id="prod456"></a> <a href="http://tr.
<a href="http://tr.abc.com/?id=qwe&media=34567" class="getitnow" id="prod123"></a>
<a href="http://tr.abc.com/?id=qwe&media=34567" class="getitnow" id="prod456"></a>
<a href="http://tr.abc.com/?id=qwe&media=34567" class="getitnow" id="prod789"></a>
这两个console.log()都返回相同的值,即旧的href值。
我想要打开窗口。打开当前URL+在changeEL函数中处理的新URL。
在这种情况下,它会打开原始URL,该URL是
我希望传递给changeEL的el对象会发生更改/更新,但情况似乎并非如此
如何将window.open设置为openas您没有将第二个参数传递给statusChangeCallback。调用statusChangeCallback(this),但函数需要第二个参数“el”。这可能是个问题吗?哦,对不起,实际上我正在使用FB应用程序。响应来自FB应用程序。让我重新构造我的代码。FB响应肯定是有价值的。
$(".getitnow").click(function(e){
e.preventDefault();
checklogin(this);
});
function checklogin(el) {
FB.getLoginStatus(function(response) {
statusChangeCallback(response, el);
});
}
function statusChangeCallback(response, el){
//process the el
console.log($(el).attr('href));
changeEL(el);
console.log($(el).attr('href));
window.open( $(el).attr('href) );
}
function changeEL(el){
var newURL = $(el).attr('href') + "&prm1=234&prm2=kjh";
$(el).attr('href', newURL);
}