我想要使用以下代码更改 iframe 的 src 并重新加载它:
当我点击按钮上的“更改”时,什么也没有发生。我做错了什么?
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script>
$('#changeframe').click(function () {
$('#declinedframe').attr('src', 'http://stackoverflow.com');
});
</script>
<input type="button" id="changeframe" value="Change">
<iframe id="declinedframe" class="embed-responsive-item" src="http://forgezilla.com" height="585" width="100%" ></iframe>
当我点击按钮上的“更改”时,什么也没有发生。我做错了什么?
$(function() { ... });
中,因为当脚本运行时按钮不存在。 - mplungjan