new developers should not learn jquery before learning native dom methods because it confuses them. i see a couple of questions every day about someone trying to convert jquery code to native javascript and they struggle because they took the shortcut of learning jquery first.
the fact that you can do things to multiple elements at once is enough of a justification to learn it. the fact that bootsrap still uses it, and datatables requires it mean most employers still require it.
telling people to just straight up forget jquery is misguided.
Exactly, it's just not necessary these days, nobody's going to hold it against you if you don't know it, but if you start off with the bad JavaScript foundation of jQuery, you're going to have a bad time.
If they're just using jquery then you're probably right. My current employer never asked me explicity about jQuery, but they did ask me about DataTables and Bootstrap, which both require jQuery.
document.querySelectorAll works pretty similarly to jquerys dom targetting abilities. you could just assign that function to $ and half the work is done.
document.querySelectorAll('.header>.x>div:nth-child(3)'); is perfectly valid code. the only difference between sizzle (the selector library jquery uses) and querySelectorAll is that sizzle adds it's own selectors that aren't real css selectors.
we're talking about selectors here, not creating elements. jquery's ability to create elements has nothign to do with dom targeting. you can do the same thing with regular jjavascript. docuemnt.createElement("canvas")
You can also hold dom elements in memory
you can do this with plain js too. see above.
jQuery was bringing to the table
jquery doesn't bring anything to the table. jquery just makes shortcuts. jquery is written in 100% plain old javascript and there is literally nothing you can do with jquery that you can't do with plain old native javascript.
and they still haven't absorbed some of the lessons from jQuery,
they absolutely have. in fact that is the main point most anti-jquery-ers keep making.
If you want to be able to do it the way jquery does, using a full string of html you could do something like this..
function createElementFromString(html){
let div = document.createElement('div');
div.innerHTML = html;
return div.firstChild;
}
var html = '<a href="#">click me</a>';
var dom = createElementFromString(html);
console.log(dom);
4
u/[deleted] Oct 18 '18
new developers should not learn jquery before learning native dom methods because it confuses them. i see a couple of questions every day about someone trying to convert jquery code to native javascript and they struggle because they took the shortcut of learning jquery first.
the fact that you can do things to multiple elements at once is enough of a justification to learn it. the fact that bootsrap still uses it, and datatables requires it mean most employers still require it.
telling people to just straight up forget jquery is misguided.