[英]How can I retrieve code from another html page using js & jquery, onclick
So, I've noticed that when using the following code for the purposes detailed in the title, that code from settings.html appears, then disappears almost instantaneously. 因此,我注意到,将以下代码用于标题中详述的目的时,来自settings.html的代码出现了,然后几乎立即消失了。
Javascript: Javascript:
function load() {
$("#paste").load("settings.html");
}
HTML: HTML:
<a href="" onclick="load();">Settings</a>
<div id="paste"></div>
However when using the following javascript/jquery instead, the browser freezes. 但是,当改用以下javascript / jquery时,浏览器将冻结。 (And the content does not load at all)
(而且内容根本不会加载)
function load() {
for (i = 0; i < 1;) {
$("#paste").load("settings.html");
}
}
What can I do to solve this? 我该怎么解决?
JavaScript Code JavaScript代码
function load() {
$("#paste").load("settings.html");
}
HTML 的HTML
<a href="javascript:void(0);" onclick="load();">Settings</a>
<div id="paste"></div>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.