this Keyword


You can use 'this' keyword to refer to the current object.
this' refers to the calling object in a method


function validate(obj, lower, upper) { 
   if ( (obj.value < lower) || (obj.value > upper) ) {
      alert('out of range');
   }
}

<input type="text" name="age" size="3"
    onChange="validate(this, 18, 99)">



© 2022 Better Solutions Limited. All Rights Reserved. © 2022 Better Solutions Limited TopPrevNext