T
T
ttaaaarrr2017-05-08 18:15:00
JavaScript
ttaaaarrr, 2017-05-08 18:15:00

How to parse html to js?

There is an html like this:

<ul id="result" class="clearfix">
     <li><a data-suffix-len="4" >слово</a></li>
     <li><a data-suffix-len="2" >слово2</a></li>
     <li><a data-suffix-len="3" >слово3</a></li>
     <li><a data-suffix-len="2" >слово4</a></li>
     <li><a data-suffix-len="2" >слово5</a></li>
</ul>

We need to put each word and data-suffix-len for it into an array like [{word: word, len: 4}, {word: word2, len: 2}]. Is there a lib for this? Knowledge at the beginning level, I did not find it on the net.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
alvvi, 2017-05-08
@alvvi

Why are there any libs, this is done on regular js using selectors.
https://www.w3schools.com/jsref/met_document_query...
https://www.w3schools.com/jsref/met_document_query...

X
xmoonlight, 2017-05-10
@xmoonlight

There is such an option: REX

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question