0

So, here's the problem I'm having. depth is a variable between 1 and 5. Lets say it's 2 at the point that this code runs. I'm trying to select the child of an li element with the class depth-2. So ideally, the selector would look like $('li.depth-2 > a[data-listIsExpanded="false"]')...and the rest doesn't really matter, because I'm pretty sure it's right. I just need to know the proper syntax for selecting the child of a concatenated string. Any help would be greatly appreciated!

$('"li.depth-"+depth > a[data-listIsExpanded="false"]').attr('data-listIsExpanded','true').parent().find('>ul').slideDown('medium');
4

1 回答 1

0

你需要

$('li.depth-' + depth + ' > a[data-listIsExpanded="false"]').attr('data-listIsExpanded','true').parent().find('>ul').slideDown('medium');
于 2013-08-16T15:54:02.293 回答