Skip to content

Instantly share code, notes, and snippets.

@conanak99
Created December 9, 2017 10:42
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
Save conanak99/074800a341c57b465418c6831a8f7333 to your computer and use it in GitHub Desktop.
// 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