Jquery 更改元素中的iframe内容
我尝试使用上面的代码来更改iframe中的内容,但它不起作用。除非我把Jquery 更改元素中的iframe内容,jquery,iframe,Jquery,Iframe,我尝试使用上面的代码来更改iframe中的内容,但它不起作用。除非我把警报(“”)位于$('#关键字框').contents().find(“#step12”).html('')之上 如果公正会生效。原因是什么,任何人都可以提供帮助?可能只是您需要等待iframe加载 由于这是我目前唯一能想到的事情,请尝试以下方法: $(document).ready(function () { $('#keywordframe').contents().find("#step12").html('')
警报(“”)
位于$('#关键字框').contents().find(“#step12”).html('')之上代码>
如果公正会生效。原因是什么,任何人都可以提供帮助?可能只是您需要等待iframe加载
由于这是我目前唯一能想到的事情,请尝试以下方法:
$(document).ready(function () {
$('#keywordframe').contents().find("#step12").html('');
$('#keywordframe').contents().find("#step12").html('11');
$('#keywordframe').contents().find("#step13").html('');
$('#keywordframe').contents().find("#step13").html('12');
$('#keywordframe').contents().find("#step14").html('');
$('#keywordframe').contents().find("#step14").html('13');
$('#keywordframe').contents().find("#step15").html('');
$('#keywordframe').contents().find("#step15").html('14');
});
我不知道它是否能解决您的问题,但值得一试。在这里工作正常。您是否验证了选择器的长度为1+而不是0?我这边不行。我把我的iframe内容像这样回复gordan:我不想放进去,因为每个html都有自己的价值
$(document).ready(function () {
$('#keywordframe').load(function() {
$('#keywordframe').contents().find("#step12").html('');
$('#keywordframe').contents().find("#step12").html('11');
$('#keywordframe').contents().find("#step13").html('');
$('#keywordframe').contents().find("#step13").html('12');
$('#keywordframe').contents().find("#step14").html('');
$('#keywordframe').contents().find("#step14").html('13');
$('#keywordframe').contents().find("#step15").html('');
$('#keywordframe').contents().find("#step15").html('14');
});
});