Applying style to li generated in loop of function
<p>@nrabinowitz</p>

<p>I am now wondering how to get the map icon when clicked to apply a style to the LI that is created in the previous section. Is that possible? I attempted below in the code but does not work. </p>

<pre><code>function(I) {
    // within the scope of this function,
    // "thismarker" will work as expected
    var listid = I + 1;
    $("&lt;li id="+I+"/&gt;")
        .html('&lt;span class="leadId"&gt;' + listid + '&lt;/span&gt;' + '&lt;div class="leadDataWrapper"&gt;&lt;div class="leadName"&gt;' + data[I][3] + ' ' + data[I][4] + '&lt;/div&gt;&lt;div class="leadDate"&gt;' + data[I][2] + '&lt;/div&gt;&lt;/div&gt;&lt;div class="leadType"&gt;&lt;img src="/images/map-' + data[I][1].toLowerCase() + '.png"&gt;&lt;/div&gt;')
        .click(function(){
            infowindow.close();
            infowindow.setContent(contentString[I]);
            map.setCenter(markers[I].position);
            infowindow.open(map, markers[I]);

        })
        .appendTo("#leadsList ul");  
    google.maps.event.addListener(marker, "click", function(e){
        infowindow.close();
        infowindow.setContent(contentString[I]);
        infowindow.open(map, markers[I]);
        $("#leadsList li #"+I).css({"background-color":"#666666"});
    });
})(I);
</code></pre>
