Additionally, the above code works as well, which is simplier and doesn't rely on the ui-accordion-link class being present. Which was posted prior. If it does not, please let me know, and I'll send you back a link to a zip where you can download my test
project that I was using. It's possible that you are using a different or older version of jquery and/or jqueryUI that this does not work in, and I would recommend you upgrade. I used jquery 1.7.1 and jquery ui 1.8.16.
Marked as answer by jayajangiti on May 02, 2012 07:02 PM
Motley
Star
13789 Points
2449 Posts
MVP
Re: select current page in jquery accordion menu in master page
Apr 30, 2012 07:15 PM|LINK
$(document).ready(function () { $("#acc2").accordion({ alwaysOpen: false, autoheight: false, header: 'a.acc2', clearStyle: true, active: $('#acc2 > li:has(a[href*="' + GetCurrentPageName() + '."]) > a') }); $("#acc1").accordion({ alwaysOpen: false, autoheight: false, header: 'a.acc1', clearStyle: true, active: $('#acc1 > li:has(a[href*="' + GetCurrentPageName() + '."]) > a') }); }); function GetCurrentPageName() { //return 'Link1'; //hard coded for testing var sPath = window.location.pathname; var sPage = sPath.substring(sPath.lastIndexOf('/') + 1); var index = sPage.indexOf('.'); sPage = sPage.substring(0, index); return sPage; }Additionally, the above code works as well, which is simplier and doesn't rely on the ui-accordion-link class being present. Which was posted prior. If it does not, please let me know, and I'll send you back a link to a zip where you can download my test project that I was using. It's possible that you are using a different or older version of jquery and/or jqueryUI that this does not work in, and I would recommend you upgrade. I used jquery 1.7.1 and jquery ui 1.8.16.