Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Put a youtube iframe on an other frame with icon close

How can I put an iframe youtube on a frame with icon close. example:- If I want to put the iframe below on frame with icon close, and if I click on icon close the iframe youtube will disappear, how can I do this?

<iframe width="440" height="215" src="http://www.youtube.com/embed/OyRQio7GfLU" frameborder="0" allowfullscreen></iframe>

Thanks

like image 539
simo9900 Avatar asked Sep 29 '16 22:09

simo9900


People also ask

How do I embed a YouTube video into an iframe?

On a computer, go to the YouTube video or playlist you want to embed. From the list of Share options, click Embed. From the box that appears, copy the HTML code. Paste the code into your website HTML.

How do I change my iframe on YouTube?

To change YouTube embed iframe video, we just need to change the src attribute value of the iframe with the new YouTube video embed URL using javaScript iframe src property.

How do I stop YouTube from clicking on my button?

Using the contentWindow.postMessage() sends a message to the particular element. In our case, we will give the command to stop the YouTube video and invoke the stopVideo() function using this method. We can either stop or pause the YouTube video using this method.


1 Answers

I'm not sure by 100% if this is what did you expect, but I hope I've helped you.

$(".button").click(function() {
  $("#x").addClass('hide');
});
.frame {
  height: auto;
  width: auto;
  padding: 20px;
  border: 1px solid black;
  position: relative;
}
.button {
  position: absolute;
  top: 5px;
  right: 5px;
  height: 20px;
  width: 20px;
  background-color: black;
  color: white;
}
.content {
  display: block;
}
.hide {
  display: none;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="frame">
  <button class='button'>X</button>
  <iframe id='x' class='content' width="440" height="215" src="http://www.youtube.com/embed/OyRQio7GfLU" frameborder="0" allowfullscreen></iframe>
</div>
like image 156
kind user Avatar answered Sep 30 '22 06:09

kind user