开发者

Is it safe to modify the document Object in javascript?

I'm wondering if I can modify the document Object like this, to guarante开发者_Go百科e the existence of document.getElementsByClassName(), or if there is some limitation on modifying document in some browsers:

if(typeof document.getElementsByClassName !== 'function')
    document.getElementsByClassName = function(class_name){
        // Custom function
    };


Yes, you can. The document object behaves like every other object in Javascript, so it's extensible.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜