【发布时间】:2013-06-14 06:54:01
【问题描述】:
请哪位朋友帮帮我...
我想要在 iframe 中更改代码的 java 脚本
<body><button>Change Code</button><iframe src="1.html">#document<html><head></head><body><form><div class="abc">
<div class="xyz">Name :<div class="form"><input name="txt_name" type="text" id="txt_name" class="forms" ></div></div>
</div></form></body></html></iframe></body>
我想更改包含在<div class="xyz"> 中的代码替换为
<div class="xyz">User Name :<input name="txt_name" type="text" id="txt_name" class="forms" ></div>
点击更改代码按钮...
脚本应该在按钮单击时运行
【问题讨论】:
-
我得到了这个问题的答案...
<script src="http://code.jquery.com/jquery-2.0.2.js"></script> <body> <button id='button1' onclick="changecode()"> Change Code</button><br /> <iframe id='iframe1' src='1.html'> </iframe> <script type="text/javascript"> function changecode(){ $('#iframe1').contents().find('div.xyz').load('2.html'); } </script> </body>
标签: javascript html iframe