Interactive Video Effect

Seeking to create a unique video hover effect on an image where, when the mouse hovers over it, a video pops up similar to examples found on this website.

I have been grappling with finding a solution for this issue over the past few months.

Does anyone possess the knowledge and skills to achieve this?

This relates to an image hover effect that I have successfully implemented. Instead of the image popping up, is there a way to make a video pop up in the same manner?

<html>
<head>
<title>Test</title>
<script type="text/javascript" src="js/jquery-1.4.1.min.js"></script>


<script type="text/javascript">


$(document).ready(function () {


    $('div.thumbnail-item').mouseenter(function(e) {

        x = e.pageX - $(this).offset().left;
        y = e.pageY - $(this).offset().top;

        $(this).css('z-index','15')
        .children("div.tooltip")
        .css({'top': y + 10,'left': x + 20,'display':'block'});

    }).mousemove(function(e) {

        x = e.pageX - $(this).offset().left;
        y = e.pageY - $(this).offset().top;

    $(this).children("div.tooltip").css({'top': y + 10,'left': x + 20});

    }).mouseleave(function() {

        $(this).css('z-index','1')
        .children("div.tooltip")
        .animate({"opacity": "hide"}, "fast");
    });

});


</script>
<style>

    .thumbnail-item { 

position: relative; 
float: left;  
margin: 0px 5px; 
     }

      .thumbnail-item a { 
display: block; 
      }

     .thumbnail-item img.thumbnail {
border:3px solid #ccc;  
     }

       .tooltip { 

display: none; 

position: absolute; 

padding: 8px 0 0 8px; 
       }

.tooltip span.overlay { 

    background: url(images/overlay.png) no-repeat; 

    position: absolute; 
    top: 0px; 
    left: 0px; 
    display: block; 
    width: 350px; 
    height: 200px;
}
</style>
   </head>
    <body>



<div class="thumbnail-item">
    <a href="#"><img src="images/Capture1.jpg" class="thumbnail"/></a>
    <div class="tooltip">
        <img src="images/2 Davis Road.jpg" alt="" width="330" height="185" />
        <span class="overlay"></span>
    </div> 
</div> 

<div class="thumbnail-item">
    <a href="#"><img src="images/Capture2.jpg" class="thumbnail"/></a>
    <div class="tooltip">
        <img src="images/Camberwell Town Hall, Roof Restoration.jpg" alt="" width="330" height="185" />
        <span class="overlay"></span>
    </div> 
</div> 

<div class="thumbnail-item">
    <a href="#"><img src="images/Capture3.jpg" class="thumbnail"/></a>
    <div class="tooltip">
        <img src="images/Children.jpg" alt="" width="330" height="185" />
        <span class="overlay"></span>
    </div> 
</div>      

<div class="clear"></div>

Answer №1

To enhance user experience on your website, you can incorporate jQuery with event listeners such as `mouseenter` and `mouseleave` to dynamically insert a video element within a tooltip. Utilizing tools like Bootstrap and jQuery UI can help create visually appealing tooltips for your web pages.

For example, here is a snippet of code using jQuery:

$(".video").on("mouseenter", function(){
    var video = "<video></video>"; // Make sure to include the src attribute, etc...

    // Implement code to display the tooltip

    $(".tooltip").append(video); // Assuming the tooltip has a class of .tooltip

    $(this).on("mouseleave", function(){
        // Add code here to hide the tooltip when the cursor leaves
    }
})

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

I am on a quest to locate the xpath for a day that is divided by the HTML line break element,

In my HTML structure, I have the following code snippet: <td class="FormLabel" valign="top"> <span class="DataLabel">Consists of:</span> </td> <td class="FormData"> <span class="BodyText"> Sunday<br> M ...

Tips for creating a new line in PHP when the value includes a comma

I am struggling to format information that includes commas into new lines. The current output I have is shown in the current display. I would like to display it with each comma creating a new line automatically. Below is my current code: <tr> <td ...

Having trouble sending the Authorization Token in a POST Ajax request - encountering an issue where the request header field authToken is being blocked by Access-Control-Allow-Headers

After obtaining the authToken by logging in, I attempted to run this code on a web browser to access the Taleo API. However, I encountered an error stating: "Request header field authToken is not allowed by Access-Control-Allow-Headers." Can anyone advis ...

After implementing ajax jQuery with Laravel 10, this page is experiencing technical difficulties

Seeking assistance from experienced individuals in dealing with Ajax jQuery within the context of Laravel. I have encountered a problem that has proven difficult for me to resolve on my own. Sample html code: <li> <a href="" onclick ...

Adjust image size dynamically while keeping the original aspect ratio

Is there a way to scale variable portrait and landscape images dynamically to fit proportionally within a browser window? You can find my current image resizing attempt here: http://jsfiddle.net/6pnCH/4/ I would like the image to be already scaled vertic ...

The design template is failing to be implemented on my personal server utilizing node.js

I've encountered an issue while developing the signup page on my local server using Bootstrap 4. The CSS is not getting applied properly when I run it locally, although it displays correctly in the browser. Can someone explain why this is happening? ...

Make sure the header spans the full width of the body

I am trying to create a header that spans the entire width of the body, but I am encountering some issues with white space on both sides. I initially attempted to set the width to 100% on the header div, but this did not eliminate the white space. I then e ...

Tips on Including Static Header and Footer in Multiple HTML Pages

What is the best way to reuse a header and footer on multiple HTML pages without repeating code? I have 5 HTML pages that all need to include the same header and footer elements. How can I efficiently reuse these components across all pages? ...

What is the best approach to passing multiple variables to a JavaScript function in HTML/PHP?

Seeking help with calling a javascript function from PHP through embedded HTML code. Below is the script: <script> // THE FOLLOWING JAVASCRIPT FUNCTION REDIRECTS TO EDITUSER.PHP AND PASSES USERID VALUE. function startMaint(mo, yr){ ...

Displaying a Bootstrap button and an input box next to each other

Looking for advice on aligning or arranging a button and input box side by side in Bootstrap without grouping. I've searched online for examples, but they all involve grouping of elements. jsfiddle: https://jsfiddle.net/erama035/p9dagmL3/3/ <div ...

What steps can I take to troubleshoot and fix the height of a div/span element?

Here is my HTML code: <div> <span style="display: inline-block;height:20px">20</span> <span style="display: inline-block;"><img src="img/ex.png"/></span> </div> The image I have in the second span is sized at ...

Unable to retrieve the following element in a JavaScript array

I am a beginner in JavaScript and I am attempting to access the next element of an array using an onclick function but so far I have not been successful. var i, len; function quiz() { var quiz_questions = [ "who is the founder of Fa ...

Adjust the size of the font for the placeholder text

I've been attempting to adjust the font size of the placeholder text. I added the font size property to the listed classes below, but for some reason, it's not taking effect. Could you please advise me on how to resolve this issue so that I can ...

Printing doesn't display CSS styling

I am currently working on creating a function to change the font color, however, I am facing issues with the CSS when it comes to printing. Here is the code I have: $('#draw').on('click', 'p', function () { if($(this).ha ...

Is it possible to display a variety of color schemes in just one console.log()?

My task involves working with an array of hexadecimal values, "colors": ["#d5dd90","#e6bb45","#ef9770"] To log these out in different colors, I used the following method: colors.forEach((value)=>{ console.log(& ...

Tips for utilizing the OR operator in jQuery

First and foremost, I want to express my gratitude to all those who are taking the time to read this, with a special thanks in advance to those who provide answers. Today, I encountered an issue while testing some code. It seems that it is not working as ...

Why does the image return an Undefined Value when clicked? Is there a solution to this issue?

Every time I click on an image, I encounter the error message "undefined." Can someone please shed some light on why this is happening and provide guidance on how to successfully retrieve and pass the value to the onclick function in this particular scen ...

Scrollmagic - Creating dynamic effects by animating body and div backgrounds using multiple tweens

I'm currently developing a website that utilizes scrollmagic to smoothly transition the color of the active div (each set to size of the screen) from black back to white as you scroll down. The issue I am facing is that the body background color does ...

Using jQuery to Validate if a Date Input Field is Empty

Currently, I have the following code snippet. $('form input[name="birthDate"])').blur(function () { var dob = $("#dob").val(); if(dob == "") { $("#dobAlert").show(); $("#laba").attr("disabled", true); } else ...

Is there a way to verify if a checkbox has been checked?

Having trouble with this code: if($('#primayins').prop('checked')) { $("#tx_nm0x0_pricingplan").val(1); } else { $("#tx_nm0x0_pricingplan").val(2); } It keeps returning false consistently ...