Created
February 24, 2016 08:44
-
-
Save pj/c375f2f8ddd8d5991be8 to your computer and use it in GitHub Desktop.
node js x-ray accessing selected element properties
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
var html = `<html> | |
<body> | |
<div id="someId"> | |
<a href="http://example.com/page1">Page 1</a> | |
<a href="http://example.com/page2">Page 2</a> | |
</div> | |
</body> | |
</html>`; | |
// If you have html like the above and you want to access properties of the links that | |
// are children of the div you need to do the following. The blank string in the bar | |
// property selects the links text. | |
x(html, '#someId a', [{foo: '@href', bar: ''}])(function(err, obj) { | |
console.log(obj); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment