Targeting $(this) within nested for each loops in jQuery

I'm trying to figure out, when iterating through some list items, how to target each "$(this)" equivalent within nested foreach loops. Here is an example of my problem:

$('li').each(function(){
        // I believe $(this) would target each li item...
    $(this).children("li").each(function(){
        // ... but how can I target each of these li items? Doesn't $(this) target the original loop?
    });
});

Answers


$('li').each(function(){
    var $this = $(this);
    $this.children("li").each(function(){
        $this; // parent li
        this; // child li
    });
});

Need Your Help

std::getline partially reads first and last line and sets eof-bit

c++ csv eof getline

I need to read csv-files with C++: the first line of the file contains all column titles, the remaining lines contain floating point data (examples below, files have been shrunk down).

Page is not redirecting

asp.net vb.net asp.net-mvc-2

I'm having a problem with ASP.net redirection.