Elements I want to get the existence of a click event, the original web page does not change and is not fixed, the script is by writing the ChromeDriver,
$. Data (ele, 'events') | | $. _data while forming (ele,' events'); Cannot access entrust binding click event,
CodePudding user response:
window. The document. The body. The addEventListener (" onclick ", function () {the console. The log (" click0 ")}) $(" body "). Click (function () { The console. The log (" click1 "); }); The console. The log ($. _data while forming ($(" body ") [0])); CodePudding user response:
reference 1st floor chinaskysun response: window. The document. The body. The addEventListener (" onclick ", function () {the console. The log (" click0 ")}) $(" body "). Click (function () { The console. The log (" click1 "); }); The console. The log ($. _data while forming ($(" body ") [0])); Not line, undefined CodePudding user response:
You look at my code can run normally? I see you are write wrong, on the basis of my change, $. _data while forming () returns the object that is not an array, without [0], you write inside the parentheses [0] see CodePudding user response:
reference 4 floor chinaskysun response: you look at my code can run normally? I see you are write wrong, on the basis of my change, $. _data while forming () returns the object that is not an array, without [0], you write inside the parentheses [0] see You this syntax with $. Data (ele, 'events') | | $. _data while forming (ele,' events'); In fact is the same, entrust get events, CodePudding user response:
You capture the last line is not have the result? How can have no binding event? You take my code to run it and see? Have with you CodePudding user response:
Determine whether the element after the jquery 1.8 binding event method The console. The log (" click "in $. _data while forming ($(" # id") [0], "events")); CodePudding user response:
If is entrusted binding will traverse the judgment in all the ancestor element The function isBind (ele, en) { Ele=$(ele); Var eo=$. _data while forming (ele [0], "events"); If (eo & amp; & En in eo) return true; Var ps=ele. Parents (). The get () Ps. Push (document, Windows); Return the ps. Some (function (t) { Var eo=$. _data while forming (t, "events"); If (eo & amp; & En in eo) { Return eo [en]. Some (function (tf) { Return $(tf) the selector, t) is (ele); }); } }); } Alert (isBind ($(" # id "), "click")); CodePudding user response:
reference sky waves on the eighth floor response: if it is to entrust the binding will traverse the judgment in all the ancestor element The function isBind (ele, en) { Ele=$(ele); Var eo=$. _data while forming (ele [0], "events"); If (eo & amp; & En in eo) return true; Var ps=ele. Parents (). The get () Ps. Push (document, Windows); Return the ps. Some (function (t) { Var eo=$. _data while forming (t, "events"); If (eo & amp; & En in eo) { Return eo [en]. Some (function (tf) { Return $(tf) the selector, t) is (ele); }); } }); } Alert (isBind ($(" # id "), "click")); Tf. The selector=undefined CodePudding user response:
Add a judgment conditions Return tf. The selector & amp; & $(tf) the selector, t) is (ele); CodePudding user response:
11 references, the sky wave response: add a judgment conditionsReturn tf. The selector & amp; & $(tf) the selector, t) is (ele); That I couldn't find entrust binding event element CodePudding user response:
11 references, the sky wave response: add a judgment conditionsReturn tf. The selector & amp; & $(tf) the selector, t) is (ele); The test script is TopJUI front frame page, as shown in figure, can get to the id="tree1365" click event, click event can't get to the li element, CodePudding user response:
Topjui.com is commissioned by yourself in the event functions, not with jquery event delegation binding agent, This oneself do entrusted to judge can't detect, CodePudding user response:
This method can only determine that I use $(" ul ") on (" click ", "li", the function (event) {}); This event delegation binding way, CodePudding user response:
reference 15 floor sky waves reply: this method can only determine that I use $(" ul ") on (" click ", "li", the function (event) {}); This event delegation way of binding, That is no way out CodePudding user response:
There is no solution CodePudding user response:
Js plug-in is not in the original web page bom object, get event handlers, Plug-in and the original web page to share only the dom, These belong to chrome security policy CodePudding user response:
Before JQuery1.8: Obj=$(' div. Event); Obj. Data (' events'); In JQuery1.8: Objs=$(' div. Event); $. _data while forming (objs [0], 'events');