Skip to content

Instantly share code, notes, and snippets.

@andrit
Created July 10, 2018 16:25
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrit/617329af17998bb9cd91572f981499b4 to your computer and use it in GitHub Desktop.
Save andrit/617329af17998bb9cd91572f981499b4 to your computer and use it in GitHub Desktop.

targeting an element on the page, pull all the values

for example, getting all the links on apage

var selector = ".field-search-result-title a";
var list = Array.prototype.slice.call(document.querySelectorAll(selector));

var process = function(){
	var nameList = [];
	list.forEach(function(elem){
		nameList.push(elem.innerHTML);
	 	//console.log(elem.innerHTML + ', ');	
	});
	console.log(nameList);
}

process();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment