<!DOCTYPE HTML><HTMLstyle= "font-size:13.5px;"><Head><MetaCharSet= "Utf-8"><title>JS Binding Event</title></Head><styletype= "Text/css">Li{width:500px;Line-height:20px;}</style><Body><ul> <Li>111111111</Li> <Li>222222222</Li> <Li>3333333333</Li></ul><DivID= "BTN">Click</Div></Body></HTML><Scriptsrc= "Jquery.1.9.0.min.js"></Script><Scripttype= "Text/javascript">$(function() {oeditor.init ();});varOeditor={ //Current DomCurrentobj:{},};oeditor.init=function(){ $("Li"). Click (function(e) {varTarget=$ (e.target); Oeditor.currentobj=Target; Current DOM alert (oEditor.currentObj.html ())})}</Script>
Above is the click to find the current element.
The following is the main sentence of the specified current element
Returns the element that triggered this event (the target node of the event).
var= $ (e.target); Oeditor.currentobj=target;
<!DOCTYPE HTML><HTMLstyle= "font-size:13.5px;"><Head><MetaCharSet= "Utf-8"><title>JS Binding Event</title></Head><styletype= "Text/css">Li{width:500px;Line-height:20px;}. Select{background:#ccc;}</style><Body><ul> <Li>111111111</Li> <Li>222222222</Li> <Li>3333333333</Li></ul><DivID= "BTN">Click</Div></Body></HTML><Scriptsrc= "Jquery.1.9.0.min.js"></Script><Scripttype= "Text/javascript">$(function() {oeditor.init (); });varOeditor={ //Current Domcurrentobj:{}, clear:function(){ $("Li"). each (function(index, Element) {$ ( This). Removeclass ("Select"); }); }};oeditor.init=function(){ $("Li"). Click (function(e) {varTarget=$ (e.target); Oeditor.currentobj=Target; Oeditor.clear (); OEditor.currentObj.addClass ("Select"); }); $("#btn"). Click (function() {alert (oEditor.currentObj.html ()); }) }</Script>
The This in the JS constructor