I am using accordion menu on an e-commerce site. The menu stays open with the options until the product page. On that page I am trying to use the breadcrumbs to match text in the menu and then apply a class to open the menu to the correct category for the page.
Here is my code:
$(document).ready(function(){
var bctext = $('#ProductBreadcrumb ul li:last-child').prev('li').children().text();
$('ul#accordion a:contains(bctext)').parent().parent().addClass('special');
});
The variable returns the correct text, and if I put a matching string ("Tomato Sauces") in the :contains
it works just like I want it to and applies the class. However when I use bctext variable it wont work.
I also tried a:contains($(bctext))
and it didn't work. Is it my syntax?
Thanks