Please tell me how to check the element, does it have a value property? If not, insert a value through innerHTML.
- The DIV element, for example, has no value, but input has. How to determine how to insert a value if we do not know what element we have. - Sergey Stepanov
|
1 answer
You can use the hasOwnProperty method to do this.
if (element.hasOwnProperty('value')) { // TODO: }
- Thanks, helped! I thought that hasOwnProperty only checks the properties of objects ... - Sergey Stepanov
- I thought so too. - Oleg
|