/ Published in: jQuery
Very useful snippet to link elements together.
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
$('#myList li').each(function() { var $li = $(this), $div = $li.find('div.content'); $li.data('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'); $firstLi.data('contentDiv').html('new content');
URL: http://jqfundamentals.com/book/index.html