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

3 Antworten

Relevanz
  • Chris
    Lv 7
    vor 6 Jahren
    Beste 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.

  • vor 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

  • vor 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.

Haben Sie noch Fragen? Jetzt beantworten lassen.