How to get the xpath by clicking an html element

后端 未结 4 2027
广开言路
广开言路 2020-12-30 13:38

I am quite new to programming and have to generate a Xpath on clicking an html element. for example :if i have clicked on text box of username then it should give me the xpa

4条回答
  •  悲哀的现实
    2020-12-30 14:26

    This could help you

    fiddle

    $('p').click(function(){
    parentEls = $(this).parents()
                .map(function () {
                      return this.tagName;
                    })
                .get().join(", ");
    
        alert(parentEls);
    
        });
    

提交回复
热议问题