I have one link in a div id where i have to disable the click event and also hidden.
here is my Div id which i need to disable click event.
<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>
the Function i wrote is :-
function disablingBookmark(){
$("#bookmarkviewall").removeAttr("href");
$("a#bookmarkviewall").removeAttr("class");
$("#bookmarkpopup").removeAttr("href");
$("a#bookmarkpopup").removeAttr("onclick");
$("a#bookmarkviewall").attr("class","greyFont tabs1");
$("#colorpickerDiv").hide();
}
this is My js file:-
$("#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);
});
});
},
the link is disable but still the click event is working.any help. please
thanks.
You can remove
hrefattribute first and usee.preventDefault()to prevent your default click function. See example code below and demo hereI have used different image on your actual code. See on Jsfiddle
Its working here. Seems like something wrong on your jsp code. Please check your code and make sure its working.