javascript - simulate click based on CSS path from Dom element -
i working on mouse activities( mouse move, click scroll etc.) want record , playback mouse activities. have been recorded mousemove want simulate click based on css path.
var csspath = function(el) { if (!(el instanceof element)) return; var path = []; while (el.nodetype === node.element_node) {     var selector = el.nodename.tolowercase();     if (el.id) {         selector += '#' + el.id;     } else {         var sib = el, nth = 1;         while (sib.nodetype === node.element_node && (sib = sib.previoussibling) && nth++);         selector += ":nth-child("+nth+")";     }     path.unshift(selector);     el = el.parentnode; } return path.join(" > ");   }
 html > body > div#div-id > div.site:nth-child(1) > div.clearfix > ul.choices > li:nth-child(5)   how can trigger click based on above css path or else based on dom.
please note i, not have id or name of dom element.
regards,
try this:
var liel = $('div#div-id > div.site:eq(1) > div.clearfix > ul.choices > li:eq(5)').get(0); var targetel = el.target; if( liel === targetel ) {      // same element } else {     // not same element }      
Comments
Post a Comment