Is there any advantage to this:
document.getElementById('mySelectBox').options[this.selectedIndex].value
over this:
document.getElementById('mySelectBox').options[selectedIndex].value
Just curious. Thanks!
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Yes, if you don’t use
this, you will be accessing a variable instead of the property in the object.Javascript isn’t object oriented, so you are never in the scope of an object, where you could access properties without specifying which object they belong to.
Anyway, if
thisrefers to the element, just use: