簡體   English   中英

<a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF

[英]<a href doesn't fire after .Click jquery function call in IE. Works fine with Chrome and FF

我的代碼:

jQuery部分:

$('#yesdownloadvideo').click(function(){
var expiryTime = parseInt($('#expirytime').val());    
$('#fade, #popuprel').fadeOut()
setCookie("emailpopup","cookie already set",expiryTime);    
});

HTML部分:

<div class="yes-btn"><a id="yesdownloadvideo" href="<%=yesbuttonlink%>.html" target="_blank" style="text-decoration:none"><input type="submit" class="yesbtn-src" value="<%=yesText%>" /></a></div>

像這樣使用preventDefault()

$('#yesdownloadvideo').click(function(e){
   e.preventDefault();
   var expiryTime = parseInt($('#expirytime').val());    
   $('#fade, #popuprel').fadeOut()
   setCookie("emailpopup","cookie already set",expiryTime);    
});

也像改變你的HTML

// Remove your submit button from link
<div class="yes-btn">
     <a id="yesdownloadvideo" href="<%=yesbuttonlink%>.html" target="_blank" 
         style="text-decoration:none"><%=yesText%></a>
</div>

link后添加提交

<div class="yes-btn">
     <a id="yesdownloadvideo" href="<%=yesbuttonlink%>.html" target="_blank" 
         style="text-decoration:none"><%=yesText%></a>
     <input type="submit" class="yesbtn-src" value="<%=yesText%>" />
</div>

您的HTML無效。 您不能在a中input任何a 從該錯誤恢復瀏覽器是不穩定的。 看來輸入正在捕獲IE中的點擊。

您可以在其中擁有一個鏈接一個提交按鈕,但不能同時擁有。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM