The Web Design Group

... Making the Web accessible to all.

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> this
pinklemon
post 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!!!
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post 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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post
Christian J
post Jul 5 2014, 02:36 PM
Post #3


.
********

Group: WDG Moderators
Posts: 9,656
Joined: 10-August 06
Member No.: 7



QUOTE(pinklemon @ Jul 5 2014, 08:12 PM) *

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.
User is offlinePM
Go to the top of the page
Toggle Multi-post QuotingQuote Post

Reply to this topicStart new topic
2 User(s) are reading this topic (2 Guests and 0 Anonymous Users)
0 Members:

 



- Lo-Fi Version Time is now: 23rd April 2024 - 11:03 AM