First of all the $ is a javascript object when you are using jquery.
So if you just use
Code:
var lis = $('#' + id).find('.' + cat);
another approach is to use a string passed to the jquery selector:
from:
Code:
var $lis = $('#' + id + ' ul .' + cat);
replace it with
Code:
var selector = '#' + id + ' ul .' + cat; // the selector is constructed first
var lis = $(selector); // and than is passed to the jquery to obtain the desired info.
Some while ago i had the same problem in desktop development and the approach above helped me.