How do I access html elements with JavaScript without the use of id? | SoloLearn: Learn to code for FREE!

+1

How do I access html elements with JavaScript without the use of id?

I would like to create a load more button on my webpage but I am confused about how to access the html elements that I wanna load until there are no more elements to load. What I want to create is a load more button that loads more articles when a user clicks on it and it also load more articles if the user clicks on it again until there are no more article left to load Please help https://code.sololearn.com/WEW250M1Y8bl/?ref=app

11/23/2020 9:24:58 PM

M○|-|FΞY 🇳🇬

18 Answers

New Answer

+3

Mofey check this. i hope this is what you looking for https://code.sololearn.com/Wj6RWKE87QTa/?ref=app

+2

Okay Med Amine Fh What I want to create is a load more button that loads more articles when a user clicks on it and it also load more articles if the user clicks on it again until there are no more article left to load

+2

document.getElementsByClassName(".button");

+2

Mofey are you using a computer or the phone ? it seems sololearn code playground not showing me the results as expected

+2

$$("article")

+2

$$("article") not $$article Where are the ( and "?

+2

Mofey you can use “document.querySelector("article:nth-child(1)");” https://code.sololearn.com/WQWRf21pIzTW/?ref=app

+1

you can select by className or tagName , this return an array of nodes: document.querySelectorAll(".myclass") document.querySelectorAll("button")

+1

sorry i didnt understand what you want to do , can you try to explain

+1

Thank you You've all been helpful

+1

Mofey glad to help you.😉

+1

Sophie Harradine please do not spam in Q/A Discussions.

0

For instance Med Amine Fh, check my code How can I substitute that of the articles for the one, two and so on without using html elements https://code.sololearn.com/WEW250M1Y8bl/?ref=app

0

Med Amine Fh, I'm using vs code

0

Gordon it says that $$article is not defined and cannot read property of length

0

Gordon, I still don't understand what you try to explain to me Please help me out

0

0

You can access by ClassName or by TagName