• <legend id='BHTN3'><style id='BHTN3'><dir id='BHTN3'><q id='BHTN3'></q></dir></style></legend>

      <tfoot id='BHTN3'></tfoot>

      <small id='BHTN3'></small><noframes id='BHTN3'>

      <i id='BHTN3'><tr id='BHTN3'><dt id='BHTN3'><q id='BHTN3'><span id='BHTN3'><b id='BHTN3'><form id='BHTN3'><ins id='BHTN3'></ins><ul id='BHTN3'></ul><sub id='BHTN3'></sub></form><legend id='BHTN3'></legend><bdo id='BHTN3'><pre id='BHTN3'><center id='BHTN3'></center></pre></bdo></b><th id='BHTN3'></th></span></q></dt></tr></i><div id='BHTN3'><tfoot id='BHTN3'></tfoot><dl id='BHTN3'><fieldset id='BHTN3'></fieldset></dl></div>
        <bdo id='BHTN3'></bdo><ul id='BHTN3'></ul>

      1. 将 HTML 作为字符串插入,不使用 JQuery

        时间:2023-10-13
      2. <i id='HXAUN'><tr id='HXAUN'><dt id='HXAUN'><q id='HXAUN'><span id='HXAUN'><b id='HXAUN'><form id='HXAUN'><ins id='HXAUN'></ins><ul id='HXAUN'></ul><sub id='HXAUN'></sub></form><legend id='HXAUN'></legend><bdo id='HXAUN'><pre id='HXAUN'><center id='HXAUN'></center></pre></bdo></b><th id='HXAUN'></th></span></q></dt></tr></i><div id='HXAUN'><tfoot id='HXAUN'></tfoot><dl id='HXAUN'><fieldset id='HXAUN'></fieldset></dl></div>
        <tfoot id='HXAUN'></tfoot>
          <legend id='HXAUN'><style id='HXAUN'><dir id='HXAUN'><q id='HXAUN'></q></dir></style></legend>
            <tbody id='HXAUN'></tbody>
        1. <small id='HXAUN'></small><noframes id='HXAUN'>

            <bdo id='HXAUN'></bdo><ul id='HXAUN'></ul>

                  本文介绍了将 HTML 作为字符串插入,不使用 JQuery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在寻找一种将包含 HTML 数据的字符串插入 div 元素的方法.该字符串是通过 XHR 加载的,无法知道其中包含哪些元素等.

                  I'm looking for a method to insert a string, which contains HTML data, into a div element. The string is loaded via XHR, and there is no way of knowing what elements and such are in it.

                  我四处搜索了一下,发现了一些可能会有所帮助,但对我来说并不完全有用的东西.我需要的是类似于 Prototype 框架中的 update() 函数的东西:http://prototypejs.org/api/element/update

                  I've searched around for a bit, and found some things that might help, but wouldn't completely work for me. What I need is something similar to the update() function from the Prototype framework: http://prototypejs.org/api/element/update

                  我正在编写的平台不允许使用框架或 JQuery.我被 Javascript 困住了.有人有什么想法吗?

                  The platform I'm writing for does not allow frameworks to be used, or JQuery. I'm stuck with Javascript. Anyone have any ideas?

                  我不能使用 innerHTML,因为它不会应用任何更新或功能,或者基本上任何应该在加载时发生的事情

                  I can't use innerHTML, as it does not apply any updates or functions or basically anything that's supposed to occur on load

                  我有一些需要发生的 onload 事件,据我所知,使用 innerHTML 不会执行 onload 事件.我错了吗?

                  I have some onload events that need to occur, and as best I know, using innerHTML does not execute onload events. Am I incorrect?

                  2 年后对于其他阅读者,我对 onload 事件有一些严重的误解.我希望它对任何元素都是有效的事件,而它仅对 <body/> 元素有效..innerHTML 是我正在寻找的正确方法,添加元素的任何额外功能都需要以其他方式手动完成.

                  EDIT 2 years later: For anyone else reading, I had some serious misconceptions about the onload event. I expected that it was a valid event for any element, while it is only valid for the <body/> element. .innerHTML is the proper method to do what I was looking for, and any extra functionality for the elements added, needs to be done manually some other way.

                  推荐答案

                  HTMLElement innerHTML 属性

                  innerHTML 属性设置或返回元素的内部 HTML.

                  The innerHTML property sets or returns the inner HTML of an element.

                  HTMLElementObject.innerHTML=text
                  

                  示例:http://jsfiddle.net/xs4Yq/

                  这篇关于将 HTML 作为字符串插入,不使用 JQuery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Web 应用程序中的跨源请求 下一篇:POST 适用于 JQuery,但不适用于 XMLHttpRequest

                  相关文章

                  最新文章

                    <bdo id='m0p55'></bdo><ul id='m0p55'></ul>
                  <i id='m0p55'><tr id='m0p55'><dt id='m0p55'><q id='m0p55'><span id='m0p55'><b id='m0p55'><form id='m0p55'><ins id='m0p55'></ins><ul id='m0p55'></ul><sub id='m0p55'></sub></form><legend id='m0p55'></legend><bdo id='m0p55'><pre id='m0p55'><center id='m0p55'></center></pre></bdo></b><th id='m0p55'></th></span></q></dt></tr></i><div id='m0p55'><tfoot id='m0p55'></tfoot><dl id='m0p55'><fieldset id='m0p55'></fieldset></dl></div>

                    1. <small id='m0p55'></small><noframes id='m0p55'>

                      <tfoot id='m0p55'></tfoot>

                      <legend id='m0p55'><style id='m0p55'><dir id='m0p55'><q id='m0p55'></q></dir></style></legend>