日期:2014-05-16 浏览次数:20375 次
<script type="text/javascript" src="jq.js"></script>
<script type="text/javascript">
$(document).ready(function () {
var xpath = '', o;
$('*').click(function (e) {
e.stopPropagation();
o = this;
xpath = this.tagName;
while (o = o.parentNode) { xpath = o.tagName + '/' + xpath; if (o.tagName == 'BODY') break; }
alert('/' + xpath);
});
});
</script>
<table><tr><td><div class="item_title">1<div class="item_content">1的内容</div></div></td></tr></table>
<div class="item_title">2<div class="item_content">2的内容</div></div>
<div class="item_title">3<div class="item_content">3的内容</div></div>