我有一個鏈接在div id我必須禁用點擊事件,也隱藏。 這裏是我的Div ID,我需要禁用點擊事件。jQuery禁用點擊
<div class="bookmark" align="left">
<div align="left">
<img src="<c:url value="/images/Bookmarks1.png">"align="absmiddle" border="0" width="18" height="18" />
<a href="#" id="bookmarkviewall" class="book tabs" style="text-decoration: none;"> Bookmark</a>
<a href="#" id="bookmarkpopup" class="book tabs" onclick="javascript:return false;">
<img alt="Add Bookmark" src="<c:url value="/images/red_plus.png"/>" align="absmiddle">
</a>
</div>
</div>
我寫的功能是: -
function disablingBookmark(){
$("#bookmarkviewall").removeAttr("href");
$("a#bookmarkviewall").removeAttr("class");
$("#bookmarkpopup").removeAttr("href");
$("a#bookmarkpopup").removeAttr("onclick");
$("a#bookmarkviewall").attr("class","greyFont tabs1");
$("#colorpickerDiv").hide();
}
這是我的js文件: -
$("#bookmarkviewall").click(function(e){
var selectedId = "#"+currentSelectedTabId;
$(selectedId).removeAttr("style");
currentSelectedTabId = null;
highlight($('#content').attr("id"));
//For hiding the popuped menu
//$("#rightHandPanelStatus").attr("recent","bookmarks");
highlightForToolBox($('#bookmarkviewall').attr("id"));
var currentNumberOfRecordsPerPage = 10;
var currentPageNumber = 1;
$.post("/core-web/bookmark/viewlist", jQuery.param({pageNumber :currentPageNumber, NumberOfRecordsPerPage :currentNumberOfRecordsPerPage, pageId:currentPageId}), function(data) {
$('#center_in').html(data);
});
});
},
鏈接是禁用,但仍然click事件是working.any幫助。請致電 。
$(「a#bookmarkpopup」)。click(function(e){e.preventDefault();}) – mshsayem 2012-04-02 05:39:12
這個問題是人們急於提供答案而沒有解釋的一個障礙。等到塵埃落定之後才能確定誰的建議是好的。 – 2012-04-02 05:40:57