Skip to content
Advertisement

How to get certain element (using JavaScript) from HTML with similar classes?

How can I get one certain element from HTML using JavaScript. I have this code.

JavaScript

I want to write “Text From Second Block”. If I write this code

JavaScript

I will get “Text From First Block”

Advertisement

Answer

instead of using queryselector you can use getElementsByClassName() and instead of enter the index number of your tag

JavaScript
User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement