JavaScript getElementsByTagName() - JavaScript Tutorial 105

Published: 27 April 2023
on channel: ChidresTechTutorials
528
14

Notes for You:: JavaScript getElementsByTagName() - JavaScript Tutorial 105

JavaScript document.getElementsByTagName("tagName");
used to access HTML elements by their tag name.

elementRef.innerHTML = "value";
used to change content of referenced HTML element.

elementRef.style.propertyName = "value";
used to apply css styles to referenced HTML element.


Example code:
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Accessing HTML Elements</title>
</head>
<body>

<h1>Heading Text</h1>
<p>Paragraph Text</p>

<h1>Heading Text</h1>
<p>Paragraph Text</p>

<h1>Heading Text</h1>
<p>Paragraph Text</p>

<h1>Heading Text</h1>
<p>Paragraph Text</p>

<script type="text/javascript">

var headings = document.getElementsByTagName("h1");

for(var i=0; i<headings.length; i++)
{
headings[i].style.backgroundColor = "gray";
headings[i].style.color = "white";
}

var paragraphs = document.getElementsByTagName("p");

for(var i=0; i<paragraphs.length; i++)
{
paragraphs[i].style.backgroundColor = "orange";
paragraphs[i].style.color = "black";
}

</script>


</body>
</html>



Note:
replace < with less-than symbol.
replace > with greater-than symbol.

=========================================

Follow the link for next video:
How to Handle Events in JavaScript - JavaScript Tutorial 106
   • How to handle JavaScript Events - Jav...  

Follow the link for previous video:
JavaScript document.getElementsByClassName() - JavaScript Tutorial 104
   • JavaScript getElementsByClassName() -...  

=========================================

JavaScript Tutorials Playlist:-
   • JavaScript Tutorials  

=========================================
Watch My Other Useful Tutorials:-

jQuery Tutorials Playlist:-
   • jQuery Tutorials  

jQuery UI Tutorials Playlist:-
   • jQuery UI Tutorials  

Bootstrap Tutorials Playlist:-
   • Bootstrap4 Tutorials  

=========================================

HI, I am Manjunath Chidre and I'm an Indian born. I make video tutorials on Computer Science, Information Technology, Animation, VFX, Multimedia, & Gaming courses. Essentially, I set my goal to help students around the world; to learn at free of cost; through my educational YouTube channel Chidre'sTechTutorials.

=========================================

Every video on my channel is made with Love and Hard work, So don't forget to Like, Comment & Share.
Please do Subscribe, Hit the bell icon & Enjoy Learning. It's FREE.

=========================================

Subscribe to our YouTube channel:-
   / chidrestechtutorials  

Join as member of our YouTube channel:-
https://www.youtube.com/chidrestechtu...

Become our Patron:-
  / chidrestechtutorials  

Visit our Website:-
https://www.chidrestechtutorials.com

Download our Notes from Instamojo:-
https://chidrestechtutorials.myinstam...

Buy our Products on Spring:-
https://chidres-tech-tutorials.creato...

=========================================
Follow us:-

Google My Business:-
https://chidrestechtutorials.business...

Google Blog:-
http://manjunathchidre.blogspot.com

LinkedIn:-
  / chidrestechtutorials  

Facebook:-
  / chidrestechtutorials  

Twitter:-
  / manjunathchidre  

Tumblr:-
  / chidrestechtutorials  

Pinterest:-
  / chidrestechtutorials  

=========================================

Despite my inconsistent uploads; Thanks for being amazing learners and still sticking with me on YouTube.

=========================================
Hash Tags:-
#ChidresTechTutorials #JavaScript #JavaScriptTutorial


On this page of the site you can watch the video online JavaScript getElementsByTagName() - JavaScript Tutorial 105 with a duration of hours minute second in good quality, which was uploaded by the user ChidresTechTutorials 27 April 2023, share the link with friends and acquaintances, this video has already been watched 528 times on youtube and it was liked by 14 viewers. Enjoy your viewing!