简体   繁体   中英

Pop-Up Info Window on Mouse Over

I would like to implement a pop-up window on mouse over to display a basic thumbnail displaying all the info about said entry.

Below is my index view:

索引检视

Below is the thumbnail window I would like to display when the mouse hovers over any of the Software Name's.

缩图

Any help is appreciate, thank you in advance!

What you could do is iterate through all the <tr> </tr> with JQuery and append a html element in which you add your thumbnail. Something like:

 $('#table tr').each(function (i, obj) {
        $(obj).mouseenter(function () {
            $('body').append("<div id='hoveringTooltip' style='position:fixed;'></div>");
            $('#hoveringTooltip').html("your thumbnail");
            $('#hoveringTooltip').css({
                "top": (obj.getBoundingClientRect().top + 20),
                "left": obj.getBoundingClientRect().left,
                "background-color": "white",
                "border": "1px solid black"
            });
        });
        $(obj).mouseleave(function () {
            $('#hoveringTooltip').remove();
        });
    })

As you can see I apply some css to the div apended in order to show it near the mouse location.

Assuming popup is the ID of your "description box":

HTML

<div id="parent">
This is the main container.
<div id="popup" style="display: none">some text here</div>
</div>

JavaScript

var e = document.getElementById('parent');
e.onmouseover = function() {
  document.getElementById('popup').style.display = 'block';
}
e.onmouseout = function() {
  document.getElementById('popup').style.display = 'none';
}

Alternatively you can get rid of JavaScript entirely and do it just with CSS:

CSS

.parent .popup {
  display: none;
}

.parent:hover .popup {
  display: block;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM