this |
this |
pinklemon |
Jul 5 2014, 01:12 PM
Post
#1
|
Advanced Member Group: Members Posts: 140 Joined: 29-June 14 Member No.: 21,166 |
Hello!
Pleas,e can somoene tell me what EXACTLY means "this" in next example: CODE <!DOCTYPE html> <html> <head> <script> function setStyle(x) { document.getElementById(x).style.background="yellow"; } </script> </head> <body> <p>A function is triggered when one of the input fields get focus. The function changes the background-color of the input field.</p> First name: <input type="text" id="fname" onfocus="setStyle(this.id)"><br> Last name: <input type="text" id="lname" onfocus="setStyle(this.id)"> </body> </html> Many thanks!!! |
Christian J |
Jul 5 2014, 02:27 PM
Post
#2
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
Please try to post new threads in relevant sub forums. This one seems to be about client side javascript, so I moved the thread here.
|
Christian J |
Jul 5 2014, 02:36 PM
Post
#3
|
. Group: WDG Moderators Posts: 9,656 Joined: 10-August 06 Member No.: 7 |
can somoene tell me what EXACTLY means "this" in next example: CODE <input type="text" id="fname" onfocus="setStyle(this.id)"> In that example it means the HTML element. In other contexts it can mean other things. See http://quirksmode.org/js/this.html for details. |
Lo-Fi Version | Time is now: 23rd April 2024 - 11:03 AM |