title: Animate resize by clicking on a link instead of the item being resized
body: <p>I'm just starting to learn javascript so I'd appreciate if someone could help me with this.</p>
  
  <p>I currently have a resize animation that happens when the iframe itself is clicked. I would like to modify it, so that the resize happens when the "resize" link is clicked, as supposed to the iframe itself but I cannot get it work.</p>
  
  <p>Thanks in advance</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$("iframe").click(function () {
      var p = $(this).parent();
      p.append('&lt;iframe src="' + $(this).attr("src") +
               '" alt="' + $(this).attr("alt") + '" class="preview" /&gt;');
      var i = $("iframe.preview", p);
      var maxWidth = i.width();
      var maxHeight = i.height();
      i.css({ width: $(this).width(), height: $(this).height() });
      i.css({ top: $(this).position().top, left: $(this).position().left });
      i.show();
      i.animate({ marginTop: -((maxHeight / 2) - (i.height() / 2)),
                  marginLeft: -((maxWidth / 2) - (i.width() / 2)),
                  width: maxWidth,
                  height: maxHeight }, 800);
      return false;
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>html, body {
  height:100%;
  text-align:center;
  }
  
  iframe {
    margin:0 auto;
    border:#444 40px solid;
    border-radius:30px;
  }
  
  #resize {
    position: absolute;
    top:0;
    left:0;
  }
  
  .preview {
      width: 1024px;
      height: 524px;
      position: absolute;
      display: none;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;a id="resize" href="#"&gt;resize&lt;/a&gt;
  
  &lt;iframe src="https://css-tricks.com" align="middle" frameborder="0" style="width: 768px; height: 524px;"&gt;&lt;/iframe&gt;
              &lt;/div&gt;</code></pre>
  </div>
  </div>
  </p>