Created
December 9, 2017 10:42
Star
You must be signed in to star a gist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Select tất cả các element chứa tiêu đề bài viết | |
let titleLinks = document.querySelectorAll('h3.knswli-title > a'); | |
// Chuyển node list thành 1 mảng | |
titleLinks = [...titleLinks]; | |
// Với mỗi phần tử trong mảng, ta lấy attribute title và link, chuyển thành object | |
let articles = titleLinks.map(link => ({ | |
title: link.getAttribute('title'), url: link.getAttribute('href') | |
})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment