The This in the JS constructor

Source: Internet
Author: User

<!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=$ (; 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= $ (;  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=$ (; Oeditor.currentobj=Target;            Oeditor.clear (); OEditor.currentObj.addClass ("Select");         }); $("#btn"). Click (function() {alert (oEditor.currentObj.html ()); })    }</Script>

The This in the JS constructor

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.