Skip to content

Latest commit

 

History

History
24 lines (15 loc) · 515 Bytes

README.md

File metadata and controls

24 lines (15 loc) · 515 Bytes

dompath

Simple experimental library which generates CSS selectors from DOM nodes.

usage

//call function, pass any element:
var path = dompath(document.body);

//get CSS selector:
var selector = path.toCSS();

//can be serialized into JSON:
var json = JSON.stringify(path);

//and deserialized later on:
var newPath = dompath(JSON.parse(json));

//you can also get element based on the path:
var element = newPath.select();

tests

Tests can be ran using karma