4 ms·
Well, since html elements already have a querySelectorAll function, you could just assign it to a new method "qsA": HTMLElement.prototype.qsA = HTMLElement
by mg 3y ago
Well, since html elements already have a querySelectorAll function, you could just assign it to a new method "qsA":
HTMLElement.prototype.qsA = HTMLElement.prototype.querySelectorAll;
Now myTable.qsA('tr') will work. You can try it right here on the HN page in the browser console:
HTMLElement.prototype.qsA = HTMLElement.prototype.querySelectorAll;
document.querySelector('#hnmain').qsA('tr');
Why do you prefer chaining?