Use docoument querySelector in Javascript tutorial 1

Use docoument querySelector in Javascript tutorial

I want to change content of Heading tag or any tag. How to do it with the help of JavaScript dynamically.

Lets first create our Heading using h1 tag

<h1>This is my H1 </h1>

Now use query selector to select the tag and save it in variable on the left side.

var myHeading = document.querySelector('h1')

We have “textContent” in JavaScript to change the content of the heading tag.

myHeading.textContent = 'Be Kind To EveryOne';
Tony BB
 

TonyBB is a Coach , marketer, hypnotist and a founder of RSKVF Production who specializes in providing simple, affordable, and easy to use solutions for Life.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: