I know there are a lot of lightweight JavaScript libraries that do the job, but for my curiosity, I tried this:
function $(a) {
b = document.querySelectorAll(a);
[].forEach.call(b, function(d) {
return d
});
}
$(".tobered,#illbered").style.border = '1px solid #f00'
And of course my console said: TypeError: $(...) is undefined
.
Lets do clearer :
Simplified 'function' :
var $ = document.querySelectorAll.bind(document)
Call which works :
$(".tobered,#illbered")[0].style.border = '1px solid #f00'
Call I need but in one line :
$(".tobered,#illbered")[0].style.border = '1px solid #f00'
$(".tobered,#illbered")[1].style.border = '1px solid #f00'
$(".tobered,#illbered")[2].style.border = '1px solid #f00'
$(".tobered,#illbered")[...].style.border = '1px solid #f00'
Clearer
How does this works ? https://api.jquery.com/multiple-selector/
Can't figure it out by reading the jquery.js
file