When writing some Javascript, I usually define upfront all the elements I need, e.g.
var $body, $header, $footer, $anInput;
$(document).ready(function () {
$body = $('body');
$header = $('div#header');
$footer = $('div#footer');
$anInput = $('form#myForm input');
};
Now, If I do something like
$body.html($body.html());
(I know, does not make sense, but it could be for instance obtained via an AJAX call).
Am I still entitled in using $header, $footer, $anInput or should I get the reference once again?
Actually, my Javascript code still works, so I would answer yes, but I suspect that I'm missing something.