2017-01-10 33 views

回答

1

你可以擴展HTMLUnknownElement的原型,但我真的不知道這是一個好主意......

HTMLUnknownElement.prototype.canThisRun = function(){console.log('hi')}; 
 

 
document.createElement('foo').canThisRun();

+0

謝謝,你救了我一天。 – waza123

+0

HTMLUnknownElement.prototype.canThisRun = function(){return function gavno(){}}; – waza123

0

這是否幫助你嗎?

var element = document.createElement("MY_FAKE_TAG"); 
 
element.canThisRun = (function(){ 
 
    //your logic here then return 
 
    return true; 
 
})(); 
 
console.log(element.canThisRun);