0

Isn't .innerHTML a method?

.innerHTML is a built-in method, but when i chosed it like right answer it disagree. Built-in functions, that do something are called methods (despite they are built-in methods)

26th Oct 2016, 8:33 PM
Iaroslav Kalytiuk
Iaroslav Kalytiuk - avatar
4 Respostas
+ 1
innerHTML is a property and not a function or method. Functions or methods always have the parentheses like getElemementById('someId') with or without arguments. innerHTML is just a property, it refers to the contents of any given node in your DOM, like the <body>, a paragraph <p>, or other.
28th Oct 2016, 10:21 PM
Bruno Freitas
Bruno Freitas - avatar
+ 2
I deleted my previous answer. I don't fully understand your question. English not my native language. Here my new answer: 1. For newbie, forget about js jargon. As long as you want to go from a to b, that will satisfied you. 2. My code: window.onload = function(){ document.body.innerHTML += "<p>Hello</p>"; document.body.innerHTML += "<p>Hello</p>".toUpperCase(); document.body.innerHTML += function(){ document.body.innerHTML = "<p>Hello</p>"; }; }; 3. You want just to display "Hello", use a statement. Refer first output. 4. How about you want make it all Caps, so you need a method .toUpperCase(). Refer second output. All someVarName with () are methods. someVarName() 5. But if you 'over-engineering' it, you still get "Hello", and it reveal your code. Refer third output. 6. Sorry, if my new answer out of context. I try my best to answer your question.
27th Oct 2016, 6:30 AM
Azman Bahari
0
but it is still method, why it appears like wrong answer. confusing newbie
26th Oct 2016, 8:43 PM
Iaroslav Kalytiuk
Iaroslav Kalytiuk - avatar
0
Thanks, your both answers, they are very helpful!!! Bruno, good point about parentesies, it is so obvious now!...
14th Sep 2017, 5:23 AM
Iaroslav Kalytiuk
Iaroslav Kalytiuk - avatar