I am using bootsrap tabs for a registration form , I changed navigation of tabs using onclick event of next and previous button . But still that tabs click works and being
$(document).ready(function(){
$("#tabs > li").click(function(){
if($(this).hasClass("disabled"))
return false;
});
});
It will be enough to work
try this for disabling a tab
$('#tab').attr('class', 'disabled');
$('tab').click(function(event){
if ($(this).hasClass('disabled')) {
return false;
}
});
I tried all suggested answers, but finally i made it work like this
if (AnyCondition) //your condition
{
$("a[data-toggle='tab'").prop('disabled', true);
$("a[data-toggle='tab'").each(function () {
$(this).prop('data-href', $(this).attr('href')); // hold you original href
$(this).attr('href', '#'); // clear href
});
$("a[data-toggle='tab'").addClass('disabled-link');
}
else
{
$("a[data-toggle='tab'").prop('disabled', false);
$("a[data-toggle='tab'").each(function () {
$(this).attr('href', $(this).prop('data-href')); // restore original href
});
$("a[data-toggle='tab'").removeClass('disabled-link');
}
// if you want to show extra messages that the tab is disabled for a reason
$("a[data-toggle='tab'").click(function(){
alert('Tab is disabled for a reason');
});