vacarsu
vacarsu

Reputation: 283

toggleClass not working

I have a series of links that change content of a span element. I'm trying to toggle the classes on them so that users know which section of a profile they are on. It does not seem to be changing the class though.

<div class="profilemenu" style="background: #e2ecfd; width: 100%">
   <a style="color: #0b439f;" class="profilemenubutton" id="profile" href="#">Profile</a>&nbsp;&nbsp; 
   <a class="profilemenubutton" id="clanactivity" href="#">Clan Activity</a>&nbsp;&nbsp; 
   <a class="profilemenubutton" id="recentsessions" href="#">Recent Sessions</a>&nbsp;&nbsp; 
   <a class="profilemenubutton" id="progress" href="#">Progress</a>
</div>

Jquery script.

$(\'a#profile\').click (function () {
$.ajax({
    type: "GET",
    url: "includes/profile.php?username='.$username.'",
    success: function(msg) {
        $(\'span#info\').html(msg);
        $(\'.active\').toggleClass("profilemenubutton");
        $(this).toggleClass("active");
    }
});
});

Upvotes: 0

Views: 691

Answers (1)

rlemon
rlemon

Reputation: 17666

A collective of the information above.

echo "$('#profile').click (function () {
$.ajax({
    type: 'GET',
    url: 'includes/profile.php?username=".$username."',
    success: function(msg) {
        $('#info').html(msg);
        $('.active').toggleClass'profilemenubutton');
        $(this).toggleClass('active');
    }
});
});";

Upvotes: 1

Related Questions