这不是 jQuery,而是纯 Javascript:
function setIframe(element,location){
var theIframe = document.createElement("iframe");
theIframe.src = location;
theIframe.setAttribute("weight", "500");
theIframe.setAttribute("width", "500");
theIframe.setAttribute("scrolling", "yes");
element.appendChild(theIframe);
}
这不是您的问题的一部分,但这是您使用 jQuery 切换 div 的方法:
标记:
<input type="button" value="Toggle Div" id="btnToggle"/>
<div id="randomContent">
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
This is random Content.
<br />
</div>
jQuery:
$(document).ready(function () {
$("#btnToggle").bind("click", function () {
$("#randomContent").toggle();
});
});