2014-09-19 11:35
浏览 235


Let's say this is my html:

<div class="picture_holder_thumb">
<div class="picture"> <a href="…"><img></a></div>
<div class="captioning"><div class="title" display: none; ">TITLE</div></div>

This creates a visual Index of Thumbnails as can be seen here:


I have a JS that shows the title of each thumbnail according to the cursors position:

script type='text/javascript'>
var mouseX;
var mouseY;
$(document).mousemove( function(e) {
 mouseX = e.pageX; 
 mouseY = e.pageY;


This is the CSS:

.captioning .title {
    position: relative;
    color: #FFF;
    display: none;


And it works, but the problem is that it shows ALL Titles at once! How can I achieve that it only shows this ".title" that "lies in" the .picture_holder_thumb that I am hovering?

Is that possible? Unfortunately I can't change the classes in to ID's because of the CMS structure…

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

2条回答 默认 最新

  • douxi4114 2014-09-19 11:37

    Use this as the context to the selector.


    $(".title", this)

    instead of


    Full code would be,

       $(".title", this).css({'top':mouseY,'left':mouseX}).fadeIn('slow');
       $(".title", this).fadeOut('slow');
    打赏 评论
  • dongyun8075 2014-09-19 11:38

    try this -

    打赏 评论

相关推荐 更多相似问题