I am trying to add class "pulse" to $choose whenever $home has class "active", and then remove pulse whenever home does not have active, both being able to execute more than just once. The function I have seems to execute once then never check again:
$(function () {
var $home = $(".tabs-group li:last-child a");
var $choose = $(".tabs-group li");
if($(home).hasClass("active")) {
$choose.addClass("pulse");
};
if(!($home).hasClass("active")) {
$choose.removeClass("pulse");
};
});
I also tried breaking it into two functions, which also did not work.
$(function () {
var $home = $(".tabs-group li:last-child a");
var $choose = $(".tabs-group .sidebar .menu li");
if(($home).hasClass("active")) {
$choose.addClass("pulse");
};
});
$(function () {
var $home = $(".tabs-group li:last-child a");
var $choose = $(".tabs-group .sidebar .menu li");
if(!($home).hasClass("active")) {
$choose.removeClass("pulse");
};
});