Saturday, April 13, 2024
 Popular · Latest · Hot · Upcoming
98
rated 0 times [  101] [ 3]  / answers: 1 / hits: 21340  / 15 Years ago, thu, april 23, 2009, 12:00:00

In Javascript, you can extend existing classes by using its prototype object:



String.prototype.getFirstLetter = function() {
return this[0];
};


Is it possible to use this method to extend DOM elements?


More From » dom

 Answers
5

you can extend the DOM by using the Element's prototype. However, this does not work in IE7 and earlier. You will need to extend the specific element, one at a time. The Prototype library does this. I recommend looking through the source to see exactly how it's done.


[#99663] Friday, April 17, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
karivictoriab

Total Points: 530
Total Questions: 90
Total Answers: 95

Location: Honduras
Member since Sun, Dec 26, 2021
2 Years ago
;