SHARE

Hey gang, in this JavaScript DOM tutorial, I’ll show youhow we can query the DOM for elements with a certain class name, or tag name. The methods we’ll use are:

– getElementsByTagName()
– getElementsByClassName()

—– COURSE LINKS:
+ Atom editor – https://atom.io/a
+ GitHub Repo – https://github.com/iamshaunjp/JavaScript-DOM-Tutorial

———————————————————————————————
Other tutorials:

—– JAVASCRIPT FOR BEGINNERS:
https://www.youtube.com/playlist?list=PL4cUxeGkcC9i9Ae2D9Ee1RvylH38dKuET

—– CSS FOR BEGINNERS:
https://www.youtube.com/playlist?list=PL4cUxeGkcC9gQeDH6xYhmO-db2mhoTSrT

—– NODE.JS TUTORIALS
https://www.youtube.com/playlist?list=PL4cUxeGkcC9gcy9lrvMJ75z9maRw4byYp

—– SUBSCRIBE TO CHANNEL – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg?sub_confirmation=1

============== The Net Ninja =====================

For more front-end development tutorials & to black-belt your coding skills, head over to – https://www.youtube.com/channel/UCW5YeuERMmlnqo4oq8vwUpg or http://thenetninja.co.uk

================== Social Links ==================

Twitter – @TheNetNinja – https://twitter.com/thenetninjauk

9 COMMENTS

  1. Really good video, I'm enjoying this series. There are a couple of 'gotchas' I'd like to point out however.

    First off, when writing a for loop, always declare your iterator variable ('i' or whatever) with the var keyword (or let if you're using JS6) so it looks like (var i = 0; i < whatever; i++). If you don't do this the iterator variable will be in the global scope and that can cause unexpected, really hard to chase down bugs. I speak from experience with this one.

    Second, Array.from() is indeed awesome, but it's also very new. Granted, it has good browser support but it's a JS6 method and if you need to support older browsers either don't use it or employ a pollyfill.

  2. An alternative way to iterate array-like objects is to use ES6's for..of, which is pretty nice: for (const el of document.getElementsByTagName('p')) { …. }

LEAVE A REPLY

Please enter your comment!
Please enter your name here