3
I’m working with functions I must pass on (Mandatorily) an element GIFT.
This function will work with the properties of this DOM element.
Example
function changeValue(elem, value){
elem.value = value;
}
var input = document.getElementsByTagName('input')[0];
changeValue(input, input.value.toUpperCase());
<input name="name" value="Guilherme" />
Doubt
- How to check if the element is really a DOM element?
and not an instance ofjQuery
or{ value : 'Guilherme'}
.
Has an update. "The Previous code didn’t work in Chrome because Node and Htmlelement are functions Instead of the expected Object."
– Guilherme Lautert
Well noted! I changed adding the current version. =)
– Laerte