how to add jQuery click event using xPath?

This question already has an answer here:

  • jquery select element by xpath 3 answers
  • How do I detect a click outside an element? 76 answers

  • This might help you.

    stackoverflow link

    function _x(STR_XPATH) {
                var xresult = document.evaluate(STR_XPATH, document, null, XPathResult.ANY_TYPE, null);
                var xnodes = [];
                var xres;
                while (xres = xresult.iterateNext()) {
                    xnodes.push(xres);
                }
    
                return xnodes;
            }
            $(_x('//div[@id="slideit"]/a[contains(@href, "javaScript:void(0)")]/..//following-sibling::div[1]')).css({
                'color': 'red'
            });
    
    链接地址: http://www.djcxy.com/p/14720.html

    上一篇: jquery div正确地打开/关闭隐藏的div

    下一篇: 如何使用xPath添加jQuery点击事件?