SO jQuery Fiddle

Test Fiddle mainly for SO Questions jQuery 1.4.3, UI 1.8.5

by jonathon

HTML

<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.5/themes/ui-lightness/jquery-ui.css">
<div id="section1">
    <p>Press one of these</p>
    <button id="button1">button1</button>
    <button id="button2">button2</button>
</div>

<div id="section2">
    <p>Now press this</p>
    <button id="buttonWhich">Which did I press?</button>
</div>

JavaScript

$("#section1 button").click(function(){
   $("#section2").data('whichButton', this);
    
    alert('The reference to "this" (' + this.id +') is now stored as data on the section2 div'); 
});

$("#buttonWhich").click(function(){
   alert($("#section2").data('whichButton').id);
});