this
JavaScript1.0+, JScript1.0+ NES2+, Nav2+, IE2+, Opera3+ Syntax
this
this.property
Description
The this keyword is used to refer to the current object and is often used to pass entire objects, such as those contained in Form instances, to functions and methods specified in scripts.
Example
Listing 6.263 contains a text box, a text area, and a button. When the user clicks the button, an onClick event handler passes the form's information, using the this keyword, to a function defined in the <head> of the document. The function opens a second, smaller window and writes several properties of the form to the page.
Listing 6.263 Using this to Pass all Form Data to a Function
<html> <head> <title> Using this in passing form information</title> ... |
Get Pure JavaScript now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.