TheGreenGentleman
TheGreenGentleman

Reputation: 95

Change the iFrame's Page by a Button Inside it via jQuery

Hi I have this two iFrame under my default.vbhtml page the code is:

<iframe class="iFrameLeft" src="Page_RequestPane.vbhtml"></iframe>
<iframe class="iFrameRight" src="Page_SKUSetup.vbhtml"></iframe>

what I want to do is when I choose a reseller and click the button "Copy SKU Setup" it the that iFrame (SKU Setup Generic) will change to a different page. the final iframe I'm targeting is:

<iframe class="iFrameLeft" src="Page_RequestPane.vbhtml"></iframe>
<iframe class="iFrameRight" src="Page_Reseller.vbhtml"></iframe>

all I have is this on jQuery, but it's wrong:

$(document).ready(function () {
  $("button").click(function () {
    $('iframe').attr('src', 'Page_Reseller.vbhtml');
    return false;
  });
});

Upvotes: 1

Views: 145

Answers (1)

Shawn G.
Shawn G.

Reputation: 622

If you are only trying to change the iFrameRight Your jQuery selector should be $('.iFrameRight')

I've modified your code a bit with the changes. You can see it below.

   $(document).ready(function () {
      $("button").click(function () {
        $('.iFrameRight').attr('src', 'Page_Reseller.vbhtml');
        return false;
      });
    });

Upvotes: 1

Related Questions