示例主页,例如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/