Answer the question
In order to leave comments, you need to log in
Get data from div to log?
How to get all values of href class"list-item__link" and content of class"list-item__date" in log
Should be something like this
http://element.ru/user/1 - 01.01.2018
http://element.ru/user/2 - 02.10.2017
http://element.ru/user/3 - 11.11.2017
<div class="list">
<li class="list-item ">
<a href="http://element.ru/user/1" class="list-item__link">
<span class="list-item__date">01.01.2018</span>
</a>
</li>
<li class="list-item ">
<a href="http://element.ru/user/2" class="list-item__link">
<span class="list-item__date">02.10.2017</span>
</a>
</li>
<li class="list-item ">
<a href="http://element.ru/user/3" class="list-item__link">
<span class="list-item__date">11.11.2017</span>
</a>
</li>
</div>
Answer the question
In order to leave comments, you need to log in
Not tested, but should work:
var links = document.querySelectorAll('.list-item__link'),
linksArray = Array.prototype.slice.call(links),
logArray = [];
linksArray.forEach(function(link){
logArray.push( link.getAttribute('href') + ' - ' + link.querySelector('.list-item__date').innerHTML );
});
var log = logArray.join('\n');
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question