javascript - 如何改变这个iframe内容?

标签 javascript jquery html iframe

示例主页,例如index.html内容:

<iframe src="a.html" width="400" height="300" frameborder="1" id="frame"></iframe>

a.html内容:

<html><body><form >
<div id="container"><div id="main"><div class="red_bl"><div class="red_br">
<div class="red_tl"><div class="red_tr"><div id="content">

<table border="0" cellspacing="0" cellpadding="0" width="100%">
<tbody id="subContent1">
<tr>another tags</tr>

<tr>
<td colspan="2" class="cell2" valign="top">
sample text
</td>
<td id="td_address" class="cell3">sample code</td>
</tr>

</tbody>
</table>


</div></div></div></div></div></div></div>
</form></body></html>

我想要改变:

<td id="td_address" class="cell3">sample code</td>

例如:

<td id="td_address" class="cell3">another text</td>

通过 jQuery 在 index.html 中。

最佳答案

这是因为您的 document.ready 不会等待 iframe 加载。

因此,您运行的代码会在 #td_address 添加到 DOM 之前执行。

有关此问题的各种解决方案(取决于您能够更改的内容),请查看 this question 的答案。

关于javascript - 如何改变这个iframe内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19801392/

相关文章:

html - Bootstrap 导航栏中的文本输入

php - 使用 JavaScript 维护动态 MySQL 表

javascript - 使用 angularjs 指令时 Fine Uploader 出现错误

javascript - jquery onload/text effect 后期 react

javascript - 多个下拉菜单——一个Jquery代码

javascript - jqPlot:重叠系列

javascript - MomentJS - 如何按名称选择一周中的所有天?

javascript - 这是对 javascript 原型(prototype)的错误使用吗?

javascript - 使用用户输入更改 Javascript 变量的值

javascript - 403 - 禁止访问 : error when calling view file in Yii