- put an object in a variable with jquery.
const $hoge = $('#hoge');
- DOM is rewritten by events etc.
$hoge.parent().html('<div id="hoge"></div>');
At this step, the variable, $hoge, is dereferenced, so I can't operate on the new element.
e.g.
$hoge.addClass('test'); // this is invalid.
Is there a way to detect $hoge in this state?
I tried...
const $hoge = $('#hoge');
console.log($hoge === $('#hoge')); // always false