开发者

DOM insertion into source

开发者 https://www.devze.com 2023-03-26 14:06 出处:网络
Im trying to insert data into the DOM with: $(\"#item_384_week_49\").append(\"test\"); <td id=\"item_384_week_49\"></td>

Im trying to insert data into the DOM with:

$("#item_384_week_49").append("test");

<td id="item_384_week_49"></td>

Works great, but the data is only displayed not inserted into the DOM.

Is there a way to do that, so that the source code contains the inserted data?

EDIT Im trying to work with docraptor to create pdf and excel files. One of the methods to do so i to refer to a web page and the page then gets converted. http://docraptor.com/documentation#referrer_based

If i have the above jquery working to insert data, the data wont be displayed in the generated file. If the above adds data to the source code, can someone please explain to me why the data isn't displayed 开发者_Python百科when the page is called?


Browsers take source code and use it to build a DOM, that DOM can then be manipulated but the source code is the source code, not a live representation of the current state of the DOM.

Use a DOM viewer if you want that. Most browsers have one built in these days, Firefox has the Firebug extension.


The data is displayed in itself means it is inserted into DOM.

Most of the browsers display the source (via view-source) as received by them from the server initially.

Use FireFox->Firebug combination to inspect the DOM and you will see all the dynamic additions to the DOM.


It is actually inserted. Are you using the "View source" option in the browser? Because the "View source" option will display the source downloaded from the server, not the modified one by javascript. You could see the changes in the source with the "Inspect element" option on the right click (depending on your browser, this is in the latest FF with Firebug and Chrome).

0

精彩评论

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