最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to create hoverover popups in Rails 3.1 - Stack Overflow

programmeradmin1浏览0评论

I have been searching for a way to implement a hover-over popup with no luck. Because it is used on so many sites I thought it would be easy to find instructions, but I am wondering if I am missing something basic. I have looked at qTips2 and a few others, but these seem like way more than I need.

I have a Rails 3.1 app and want to display more details when a user hovers over a line in a table. Is this something built into Rails that I am missing, or do I need an add-on?

I sure would appreciate someone pointing me in the right direction.

I have been searching for a way to implement a hover-over popup with no luck. Because it is used on so many sites I thought it would be easy to find instructions, but I am wondering if I am missing something basic. I have looked at qTips2 and a few others, but these seem like way more than I need.

I have a Rails 3.1 app and want to display more details when a user hovers over a line in a table. Is this something built into Rails that I am missing, or do I need an add-on?

I sure would appreciate someone pointing me in the right direction.

Share Improve this question edited Oct 30, 2020 at 15:57 Temani Afif 273k28 gold badges363 silver badges482 bronze badges asked Dec 22, 2011 at 19:45 SteveO7SteveO7 2,4603 gold badges32 silver badges41 bronze badges 5
  • That would be a simple hovering div. – Sergio Tulentsev Commented Dec 22, 2011 at 19:50
  • This isn't a Rails question, but rather a CSS or JavaScript question. – Wizard of Ogz Commented Dec 22, 2011 at 19:53
  • Ha! javascript and css tags were added before I could get to it. – Wizard of Ogz Commented Dec 22, 2011 at 19:54
  • We'll need a bit more explanation: 1) what do you mean with 'hover-over popup' (just the default browser tooltip, a styleable multiline div,...?) 2) what does your table html look like, and what items should trigger the mouseover? – ptriek Commented Dec 22, 2011 at 19:59
  • 1 This should be marked as a duplicate of e.g. stackoverflow.com/questions/3559467/…, stackoverflow.com/questions/18359193/plain-javascript-tooltip or stackoverflow.com/questions/11683620/…. The currently shown duplicate has been deleted. – Ilmari Karonen Commented Jul 16, 2019 at 16:55
Add a comment  | 

2 Answers 2

Reset to default 11

Use some CSS and Javascript!

Here's an example you can play with: http://jsfiddle.net/cdpZg/

Copying it here, just in case.

HTML:

<div id='user'>I am a user. Move your mouse over me</div>
<div id='popup'>Extended info about a user</div>
<div>I a piece of useless information. No use hovering over me.</div>

CSS:

#popup {
    height: 50px;
    width: 200px;
    text-align: center;
    vertical-align:middle;
    background-color: cornflowerblue;
    color: white;
    display: none;
    padding-top: 8px;
    position: absolute;
}

Javascript:

$(document).ready(function() {
    $('#user').hover(function() {
        $('#popup').show();
    }, function() {
        $('#popup').hide();
    });
});

Just set the title on your link like this

<a title="Some text that will show up when I hover over this link">My link</a>
发布评论

评论列表(0)

  1. 暂无评论