Jquery has a. parents ().
For example, if you choose a div id as test, if you want to complete xpath, $("#test "). Parents (); What you get is an array,
var aa =[];
$('#test ')。 Parents (). each(function(){
aa . push(this . tagname);
});
After you get the tag name, you can replace it with xpath, but pay attention to the fact that the last element of the body should be html. You are not sure. Anyway, it's like this on Firefox.