0

sample main page for example index.html content :

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

a.html content :

<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>

i want change :

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

to for example :

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

by jQuery In index.html .

barnameha
  • 371
  • 2
  • 17

2 Answers2

1

With JQuery:

$('#frame').contents().find('td#td_address').html('another text');
Don Rhummy
  • 24,730
  • 42
  • 175
  • 330
1

This is because your document.ready doesn't wait for the iframe to load.

Therefore, the code that you run is executed before #td_address is added to DOM.

For various solutions to this problem (depending on what are you able to change), look at answers to this question.

Community
  • 1
  • 1
Michał Rybak
  • 8,648
  • 3
  • 42
  • 54