使用带有链接的jquery而不是按钮更改iframe src

使用带有链接的jquery而不是按钮更改iframe src,jquery,Jquery,我有以下代码,可以通过一个按钮成功地更改iframe src。如何用文本链接替换按钮 <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> <input type="button" id="changeframe" value="Change"> <iframe id="declinedframe" class="embed-r

我有以下代码,可以通过一个按钮成功地更改iframe src。如何用文本链接替换按钮

<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>

<input type="button" id="changeframe" value="Change">

<iframe id="declinedframe" class="embed-responsive-item" src="http://forgezilla.com" height="585" width="100%" ></iframe>

// Go Last since changeframe hasn't exist yet.
<script>
  $('#changeframe').click(function () {
      $('#declinedframe').attr('src', 'http://stackoverflow.com');
  });
</script>

//因为changeframe还不存在,所以最后一步。
$('#changeframe')。单击(函数(){
$('declinedframe').attr('src','http://stackoverflow.com');
});
请回复

<input type="button" id="changeframe" value="Change">



这应该是可行的,你不需要jQuery或JavaScript来完成你想做的事情,你只需要HTML

  • 关于
    textlink是什么意思<代码>@Arya请检查此项,这可能会有所帮助
    <a href="#" id="changeframe">Change</a>