There is a problem mainly with using
thisoutside the function (
function) is a global object and does not point to the intended object
Below are some helpful codes and links, but basically it is recommended that you understand them systematically in books.
this references vary by context.
However, although it may vary, it does not have the functionality that the questioner expected.
The code in question expects
this has any other syntax to do so.
this can refer to the object being initialized is sometimes used primarily for functions (constructors) called by
In , what the question code
this refers to is the global object (same as
window for browsers).Please check the code below.
Leave as much of the code form of the question as possible:
There is a problem with how to initialize variables.References to
this in creating values for initialization of the variable
element are not what you expect.Therefore,
undefined and references
undefined.options leading to this error: "Properties cannot be viewed."
Also, it is not necessary to combine the variables used this time as
element properties at this time.You can initialize each variable in order as follows:
Furthermore, for this process, the value of the option selected in select should be obtained at the time of execution of the option selected in select.This is because even if the selected option changes, the above substitution will not be re-executed and the value will not be updated.
If you think about that, you can see that there is no need to use variables in this process.For example:
© 2022 OneMinuteCode. All rights reserved.