Skip to content

Instantly share code, notes, and snippets.

@kensnyder
Last active December 10, 2015 22:59
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 kensnyder/4506420 to your computer and use it in GitHub Desktop.
Save kensnyder/4506420 to your computer and use it in GitHub Desktop.
Quick and Dirty jQuery-like function for Casper
function qsa(sel, each) {
return [].map.call(document.querySelectorAll(sel) || [], each || function(el) {return el});
}
// usage:
qsa('a[href*="/reports/"], .legend', function(el) {
el.style.visibility = 'hidden';
});
// or
var hrefs = qsa('a[href]', function(el) {
return el.href;
});
// or
var divs = qsa('div');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment