Skip to content

Instantly share code, notes, and snippets.

@kensnyder

kensnyder/casper-qsa.js

Last active Dec 10, 2015
Embed
What would you like to do?
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