I have the following:
$('th').click(function() {
var $th = $(this);
...
});
Using the closure scope, I want to say:
var $th;
$('th').click(function() {
if ($th !== $(this)) {
$th = $(this);
...
}
});
Note: This code is just prior to </body>, so I won’t need $(function() {});
You should check whether the underlying DOM elements are equal:
(You could also store
thisitself without calling$)