是否有机会在 Form 对象上使用原型(prototype),这是行不通的:
Form.prototype.myFunc=function()
{
alert('OK!');
}
另一方面,String 对象是可扩展的,例如:
String.prototype.trim = function() {
return this.replace(/^\s\s*/, '').replace(/\s\s*$/, '');
}
最佳答案
如果你的意思是HTMLFormElement
,那么它应该是
HTMLFormElement.prototype.myFunc=function() {
alert('OK!');
};
关于javascript - 使用原型(prototype)扩展 Javascript Form 对象,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11428338/