Edit this page

up.fragment up.fragment.toTarget(element, [options])
JavaScript function

Derives a CSS selector that matches the given element as good as possible.

If no target can be derived and verified, an error up.CannotTarget is thrown.


element = up.element.createFromHTML('<span class="klass">...</span>')
selector = up.fragment.toTarget(element) // returns '.klass'


element Elementorstring

The element for which to create a selector.

When a string is given, it is returned unchanged.

[options.origin] Element optional