I’ve been trying to figure this one out for about 2 days and cant understand why this isn’t working.
Say for example I declare a variable “ul” and want to say var + li display red.
$("document").ready(function () {
var menu = $("ul");
$(menu + " li").css("color", "red");
});
All list items should now be red. What am I doing wrong?
Example: http://jsbin.com/izela
To change all the direct children to red you can use
If you require all li’s within the ul (nested ul>li>ul>li) then use .find