开发者

Unable to addclass to an active sub li in Jquery accordion

开发者 https://www.devze.com 2023-01-03 22:42 出处:网络
I am using Jquery Accordion with a UL contained within each section and I cant figure out how to add a class to indicate the active link.

I am using Jquery Accordion with a UL contained within each section and I cant figure out how to add a class to indicate the active link.

I have searched my head-off but the only thing I can find doesnt work with the Acco开发者_开发知识库rdion:

$(document).ready(function(){
  var path = location.pathname.substring(1);
  if ( path )
    $('#accordion1 a[href$="' + path + '"]').attr('class', 'activelink');
});

Please help, as I am premeturely going bald!


Why not use addClass?

$('#accordion1 a[href$="' + path + '"]').addClass('activelink');
0

精彩评论

暂无评论...
验证码 换一张
取 消