its easy to think like this way : the html page is the document itself, then you select the id=“somename” or name=“somename” to select the element you want to focus on, then the [0] tells you which forms in case there is more than one of the same element you are looking for, then select it’s property association ( .value or .innerHTML)
docuement.getElementByID(“somename”) or getElementByName(“somename”) — you must remember that “somename” must exist in the form id or name attribute.
The tertarea doesn’t even have that name attribute. Also I don’t think you need to put the word var in the cosole. Just mention the name of the variable then = and then the code. Atleast in firefox I didn’t had to mention it. I think it would be the same in chrome too. I might be wrong though.
Medal-hunting session has already started? So early this year. :p
You never have to use ‘var’ in JavaScript. However, it is good practice to do so to avoid mistakes and polluting the global scope. In some cases, like recursive functions, not using it can cause a lot of confusion. :)
It’s just part of the language that you don’t have to. If you don’t, the variable will be looked for in the available scopes (current block, current function, [s]calling function,[/s] etc.) and if it’s not found, it will be created in the global scope.
EDIT: Scope of calling function is not used, of course. I meant the function in which a function is defined.
You must be logged in to reply to this discussion.
Login
1 of 10
This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.