0

I currently have this code (this is the only code in the js file)

if ($('body').hasClass('home')) { 
('#home_link').addClass('home').removeClass('test_class')};

I'm trying to add a home class to a li item with id home_link if the body has a class home and remove test_class in the process.

(Doesn't seem to work, all help would be appreciated)

4

1 回答 1

3

看起来你缺少一个$

if ($('body').hasClass('home')) 
{ 
    $('#home_link').addClass('home').removeClass('test_class');
}
于 2011-12-06T13:11:17.813 回答