matthew s matthew s - 25 days ago 6
HTML Question

Trying to get iframe to appear on hover

currently i am working on a website for a fictional event as part of a project im doing so i can get myself back up to speed with web development for university. Currently i am trying to get a countdown timer to appear on hover. However im not the best at js and i am leaving it for another day. What i want to know is if there is a way for an iframe to appear on hover.

This is what i have:

<div id="sub1" onmouseover="<iframe src="$('#countdown').load('https://days.to/22-january/2017 #countdown');>some text</div>


Granted i get this is pretty butchered. Any help or suggestions are appreciated

Answer

Use jQuery! Sorry for the ugly script, I'm sure you can do better :)

$('#idToHover').hover(function(){
  $('#idModal').css("display", "block");
})

$('#idToHover').mouseout(function(){
  $('#idModal').css("display", "none");
})
#idModal{
display: none;  
}
<html>
  <head>
    <script
  src="https://code.jquery.com/jquery-3.1.1.slim.js"
  integrity="sha256-5i/mQ300M779N2OVDrl16lbohwXNUdzL/R2aVUXyXWA="
  crossorigin="anonymous"></script>
  </head>
 
  <body>
   
    <div id="idToHover"> Hello World </div>
    <div id="idModal">
      <iframe src="http://www.w3schools.com"></iframe>
    </div>  
    
  </body>
</html>