开发者

Is it safe to modify the document Object in javascript?

开发者 https://www.devze.com 2023-03-20 15:52 出处:网络
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

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

精彩评论

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