Can I use the data () function to store the dom element (or jQuery element) on another element? (see code below)
Does it save it by value or by reference? Is this a good practice?
I want to be able to quickly and easily find the sub element (see code below) of the main element, for example:
$slave = $('.some .path .to .slave'); $master = $('.some .path .to .master'); $master.data('slave', $slave); $master.click(function (){ $(this).data('slave').toggle() });
(Obviously, the code is stupid, but I'm actually sorting through a lot of subordinate and subordinate elements.)
source share