我給每個
<a>
都加了個window.location.href,然後給一個a標簽返回return false,但是不能取消
還是跳轉了?
$("#remove").click(function(){
var $tr = $(this).parent().parent();
var title = $.trim($tr.find("td:first").text());
var flag = confirm("您確定要刪除"+title+"的信息嗎?");
if(flag){
return true;
}
return false;
});
$("a").click(function() {
var serializeVal = $(":hidden").serialize();
href = this.href + "&" + serializeVal;
window.location.href = href;
return false;
});
#remove也是一個a標簽
return false阻止的是默認的href跳轉,你用js跳轉沒用。你應該判斷是不是remove對象,是就不要location.href
$("a").click(function () {
if (this.id == 'remove') return ;//注意這裡
var serializeVal = $(":hidden").serialize();
href = this.href + "&" + serializeVal;
window.location.href = href;
return false;
});