twitter-bootstrap-wizard
twitter-bootstrap-wizard copied to clipboard
cant add visited class to all li's before the current active li
Hello.
I would like to add a visited class to all li's before the current active li but for some reason it will not work.
this is my code:
$("#rootwizard").find("li.current").prevAll("li").addClass("visited");
any sugestions ?
try $("#rootwizard").find("li.active").prevAll("li").addClass("visited");
Not Working
$("#rootwizard").find("li.active").prevAll("li").addClass("visited");
@Arunvelvj The code works fine in my project.
As I think the syntax isn't wrong, so please check whether the $("#rootwizard")
, $("#rootwizard").find("li.active")
, $("#rootwizard").find("li.active").prevAll("li")
returns the right objects.
Note: do not test it in the first tab, that means the prevAll is empty, try it in the second or the last tab.
Hi,
$('#ap').bootstrapWizard({
'onTabShow': function(tab, navigation, index) {
var $total = navigation.find('li').length - 1;
var $current = index;
var $percent = ($current/$total) * 100;
$('#ap .progress-bar').css({width:$percent+'%'});
$("#ap").find("li.active").prevAll("li").addClass("visited");
},
onTabClick: function(tab, navigation, index) {
return false;
}
});
Not Working.Help Me.
@Arunvelvj use navigation.find("li.active").prevAll("li").addClass("visited");
but not $("#ap").find("li.active").prevAll("li").addClass("visited");
.
I thins it's a typo error.
$('#ap').bootstrapWizard({
onTabShow: function(tab, navigation, index) {
$("#ap").find("li.active").prevAll("li").addClass("visited");
}
});
The problem with above code is that it takes into account the the previous "li" element and not the current one (the one you clicked).
A simple solution to this is to take into account the current "li" element. You can do that by replacing $("#ap").find("li.active")
with tab
. It will look something like this -
$('#ap').bootstrapWizard({
onTabShow: function(tab, navigation, index) {
tab.prevAll("li").addClass("visited");
}
});
Hope it helps!