Last active
October 22, 2015 13:46
-
-
Save abhisekp/5b1ae052cf9105b3f2ff to your computer and use it in GitHub Desktop.
Sitepoint Courses - URL Generator
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
function URL(url, title) { | |
this.url = url; | |
this.title = title || url; | |
} | |
var contents = $('.Contents'); | |
// console.log(contents); | |
var contentRow = contents.children('.Contents_row'); | |
var urls = []; | |
contentRow.each(function (ind, row) { | |
// console.log(row); | |
var title = $(row).children('.Contents_title').html().trim(); | |
var url = $(row).children('.Contents_actions').children('.Contents_button'); | |
//console.log(url); | |
if(url && url[0]) { | |
//console.log(url[0]); | |
url = url[0].getAttribute('href'); | |
//url = url[0].getAttribute('href'); | |
urls.push(new URL(url, title)); | |
} | |
}); | |
urls.forEach(function (url) { | |
console.log(url.url); | |
}); | |
urls.forEach(function (url) { | |
console.log(url.title); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment