Yahoo Clever wird am 4. Mai 2021 (Eastern Time, Zeitzone US-Ostküste) eingestellt. Ab dem 20. April 2021 (Eastern Time) ist die Website von Yahoo Clever nur noch im reinen Lesemodus verfügbar. Andere Yahoo Produkte oder Dienste oder Ihr Yahoo Account sind von diesen Änderungen nicht betroffen. Auf dieser Hilfeseite finden Sie weitere Informationen zur Einstellung von Yahoo Clever und dazu, wie Sie Ihre Daten herunterladen.
In the following code, what is 'this' referring to.?
Is it referring to the node that was just appended to vacation?
![Attachment image](https://s.yimg.com/tr/i/bfa2f273968f4295be3536b3c9c1783b_A.png)
3 Antworten
- ChrisLv 7vor 6 JahrenBeste Antwort
$(x).on('click', y);
sets y as click handler for x. The actual JavaScript code is
document.querySelector( "button" ).onclick = function() {
...// "this" is used in here
};
Since onclick is a member of the button object, "this" refers to the button.
- JasonAmazingLv 5vor 6 Jahren
This piece of code executes upon complete page load. It sets on click function for the button.
Once you click the button it would set element,probably div with id vacation, to text 'From 399' and then remove the button so it can't be clicked again
- dewcoonsLv 7vor 6 Jahren
In Java, "this" is used to refer to whatever object currently has the "focus" in the program. In the code that you gave, it would be the button that was selected in the line before.
Often when you are in a subroutine you have no way of knowing what object will be selected. "This" means uses what the current object is. You have to backtrack in the code to determine what "this" is.