JQuery html() vs. innerHTML

后端 未结 7 1961
不知归路
不知归路 2020-11-28 22:08

Can I completely rely upon jQuery\'s html() method behaving identical to innerHTML? Is there any difference between innerHTML and jQue

7条回答
  •  孤城傲影
    2020-11-28 22:50

    To answer your question:

    .html() will just call .innerHTML after doing some checks for nodeTypes and stuff. It also uses a try/catch block where it tries to use innerHTML first and if that fails, it'll fallback gracefully to jQuery's .empty() + append()

提交回复
热议问题