Reputation: 822
I have a simple menu with this structure:
<ul class="navigation">
<li><a href="javascript:void(0)" onclick="javascript:dataTable()">Preview all record</a></li>
</ul>
In some cases in my project I need to disable calling dataTable() function when user clicking on this tag
I am using this
$('ul.navigation a').click(function(event){
event.preventDefault();
});
but it doesn't work with me
Upvotes: 1
Views: 379
Reputation: 28147
You can use a variable to store whether to call dataTable() or not:
onclick="javascript:if(showTable)dataTable()"
Upvotes: 0
Reputation: 601
Try save the value and set the onclick
attribute with nothing:
var tmpVal = $("ul.navigation a").attr("onclick");
$("ul.navigation a").attr("onclick","");
And you can restore the value again :
$("ul.navigation a").attr("onclick",tmpVal );
Upvotes: 0
Reputation: 262939
Try removing the onclick
HTML attributes instead:
$("ul.navigation a").removeAttr("onclick");
Upvotes: 3