Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
82
rated 0 times [  88] [ 6]  / answers: 1 / hits: 80222  / 13 Years ago, tue, july 12, 2011, 12:00:00

I'm receiving this error using the following javascript code:



function tempTest(evt) {
alert(evt.currentTarget.id);
ct = document.getElementById(evt.currentTarget.id);
rslt = document.getElementById('rslt');
var props;
for (var prop in ct) {
if (ct.hasOwnProperty(prop)) {
propVal = ct[prop];
var propDat = prop + ' = ' + propVal;
props += propDat + '<br/>';
}
}
rslt.innerHTML = props;
}


This one has me puzzled. Any ideas?


More From » object

 Answers
9

Not all the properties of a HTML element are primitives. for example, parent, childs etc are also HTML elements. You can't just use them as strings or numbers.

You need to add there a condition and use that property accordingly.


[#91224] Monday, July 11, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
jeffn

Total Points: 559
Total Questions: 81
Total Answers: 103

Location: Spain
Member since Thu, Dec 23, 2021
2 Years ago
;