How to add my own methods to HTMLElement object?

后端 未结 4 1538
你的背包
你的背包 2020-11-27 22:25

For example for this.parentNode I would like to just write this.p or instead of document.getElementById(\'someid\') just write d

4条回答
  •  栀梦
    栀梦 (楼主)
    2020-11-27 22:45

    In a word, don't. It is best not to modify objects you don't own.

    This is particularly true for HTMLElement, which you cannot modify in some browsers.

提交回复
热议问题