title: How to add if condition to $(window).resize event in jquery?
body: <p>I m trying to make all embedded videos responsive since I couldn't find a good solution to make a video responsive using bootstrap 3. Using the below code I can make any video responsive. But I want to add If condition to the below code so that if window is resized, still the code does the job.</p>
  
  <p>my jquery code :</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>$(document).ready(function(){
   function show(){
    var containerWidth = $(".col-video").width();
    $('iframe').each(function(){ 
     var iframeWidth = $(this).attr("width");
     var iframeHeight = $(this).attr("height");
        var flag = containerWidth / iframeWidth;
        var newHeight = iframeHeight * flag;
     $(this).attr("width", "100%");
     $(this).attr("height", newHeight);
    });
    $('video').each(function(){ 
     var videoWidth = $(this).attr("width");
     var videoHeight = $(this).attr("height");
        var flag = containerWidth / videoWidth;
        var newHeight = videoHeight * flag;
     $(this).attr("width", "100%");
     $(this).attr("height", newHeight);
    });
   }
   show();
  });</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;!DOCTYPE html&gt;
  &lt;html lang="en"&gt;
    &lt;head&gt;
      &lt;meta charset="utf-8"&gt;
      &lt;meta http-equiv="X-UA-Compatible" content="IE=edge"&gt;
      &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
      &lt;title&gt;Bootstrap 101 Template&lt;/title&gt;
      &lt;link href="bootstrap.min.css" rel="stylesheet"&gt;
      &lt;link href="style.css" rel="stylesheet"&gt;
    &lt;body&gt;
      &lt;div class="container"&gt;
        &lt;div class="row"&gt;
          &lt;div class="col-md-6 col-video"&gt;
            &lt;h1&gt;Hello World&lt;/h1&gt;
            &lt;iframe width="560" height="315" src="https://www.youtube.com/embed/kIsscNG9Q54" frameborder="0" allowfullscreen&gt;&lt;/iframe&gt;
            &lt;iframe src="https://www.facebook.com/plugins/video.php?href=https%3A%2F%2Fwww.facebook.com%2Fskillinprogramming%2Fvideos%2F1356766841067995%2F&amp;show_text=0&amp;width=400" width="400" height="400" style="border:none;overflow:hidden" scrolling="no" frameborder="0" allowTransparency="true" allowFullScreen="true"&gt;&lt;/iframe&gt;
            &lt;video src="video.mp4" controls&gt;&lt;/video&gt;
          &lt;/div&gt;
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;script src="jquery.min.js"&gt;&lt;/script&gt;
      &lt;script src="bootstrap.min.js"&gt;&lt;/script&gt;
      &lt;script src="test.js"&gt;&lt;/script&gt;
    &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>