Sha256: 3a7dcb3acfed45091a48d2f19f6505b527633a0db43f34bcfcf27371390b61f5

Contents?: true

Size: 713 Bytes

Versions: 28

Compression:

Stored size: 713 Bytes

Contents

// from Blixt @ http://stackoverflow.com/questions/2206958/best-way-to-reference-an-element-with-jquery

jQuery.fn.getPath = function () {
    if (this.length != 1) throw 'Requires one element.';

    if (this.attr("id")) return "#"+this.attr("id");

    var path, node = this;
    while (node.length) {
        var realNode = node[0], name = realNode.localName;
        if (!name) break;
        name = name.toLowerCase();

        var parent = node.parent();

        var siblings = parent.children(name);
        if (siblings.length > 1) {
            name += ':eq(' + siblings.index(realNode) + ')';
        }

        path = name + (path ? '>' + path : '');
        node = parent;
    }

    return path;
};

Version data entries

28 entries across 28 versions & 1 rubygems

Version Path
hobo_jquery-2.0.0.pre6 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-2.0.0.pre5 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-2.0.0.pre4 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-2.0.0.pre3 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-2.0.0.pre2 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-2.0.0.pre1 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-1.4.0.pre8 vendor/assets/javascripts/jquery.getPath.js
hobo_jquery-1.4.0.pre7 vendor/assets/javascripts/jquery.getPath.js