Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

get all links from html javascript

var rawHTML = '<html><body><a href="foo">bar</a><a href="narf">zort</a></body></html>';

var doc = document.createElement("html");
doc.innerHTML = rawHTML;
var links = doc.getElementsByTagName("a")
var urls = [];

for (var i=0; i<links.length; i++) {
    urls.push(links[i].getAttribute("href"));
}
alert(urls)
Comment

PREVIOUS NEXT
Code Example
Javascript :: jquery close another dialog 
Javascript :: find smallest number in array js 
Javascript :: jquery select specific radio button by value 
Javascript :: cannot use import statement outside a module in jest 
Javascript :: formik stepper form 
Javascript :: js listen for class change event 
Javascript :: how to check consecutive characters in javascript 
Javascript :: react img not showing 
Javascript :: javascript alert on refresh 
Javascript :: javscript foreach with click listener 
Javascript :: start angular app server 
Javascript :: fibonacci sums javascript 
Javascript :: ajax post variable values 
Javascript :: remove node module 
Javascript :: see all functions in a website with console 
Javascript :: flip a coin javascript 
Javascript :: nuxt input mask 
Javascript :: get nth character of string javascript 
Javascript :: javascript check if required 
Javascript :: regular expression javascript password strength 
Javascript :: install react router dom 
Javascript :: jquery select a dynamic element 
Javascript :: discord js on message 
Javascript :: mongoose delete property 
Javascript :: get n number of elements from array javascript 
Javascript :: rect p5js 
Javascript :: react is there a safe area view for android 
Javascript :: js function pick properties from object 
Javascript :: js read from json 
Javascript :: delete all node_modules folders recursively windows 
ADD CONTENT
Topic
Content
Source link
Name
2+5 =