Return to Snippet

Revision: 45186
at April 27, 2011 02:13 by 1man

Initial Code
$('#myList li').each(function() {
    var $li = $(this), $div = $li.find('div.content');
    $'contentDiv', $div);

// later, we don't have to find the div again;
// we can just read it from the list item's data
var $firstLi = $('#myList li:first');
$'contentDiv').html('new content');

Initial URL

Initial Description
Very useful snippet to link elements together.

Initial Title
Store the relationship between elements using .data()

Initial Tags

Initial Language