0
我的jQuery代碼與我的鏈接衝突,導致它們不能在新窗口中打開「target = _blank」?我的jQuery代碼與我的鏈接衝突?
onReady:function(){
$('a').click(function(event) {
event.preventDefault();
CookieControl.setConsent(true);
CookieControl.closeAndHide();
window.location = $(this).attr('href');
});
},
受影響的鏈接<a href="www.google.com" target="_blank">Link</a>
這是因爲你正在調用[event.preventDefault()](https://api.jquery.com/event.preventdefault/),這會阻止所有鏈接上的click事件的默認操作。 –
當我將該行註釋掉時,網站上的鏈接正常工作,但現在它們會載入父窗口和新窗口 –
請使用其中一個鏈接的代碼更新您的問題。 –