This is my 2nd post for the daily-post project. Today I learned a bit about querySelector in JS. I suggest you copy paste the following code in your Sublime Text and save it as your-desired-filename.html on desktop or your sandbox folder.
This is such a simple trick to turn your static page into a dynamic one!
- We basically write `I love Batman` text inside the paragraph tag p.
- Then use the querySelector to select the first occurrence of p tag in the source code.
- Save that as reference in variable t.
- Add an event listener to it which will trigger myFunction when clicked
- myFunction will prompt us to enter a name and then modify the content inside the variable t.
That’s all. Simple but useful. Expect more JS in my future posts 🙂