0

我正在使用 jQuery 悬停功能更改类的不透明度。注意:我没有使用

<script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js">
</script>

这是我的代码:

<script type="text/javascript">
    $(document).ready(function(){
        $(".thumbnail_image_related_project .transparent_font").css({'opacity' : '0'});
        $(".thumbnail_image_related_project").hover(
            function(){
                $(this).children(".transparent_font").stop().animate({'opacity' : '0.7'}, 300); 
             },
            function(){
                $(this).children(".transparent_font").stop().animate({'opacity' : '0'}, 300); 
           }
        );
    });
</script>

此代码在笔记本电脑上完美运行,但在智能手机上却不行。问题:当我单击元素时,动画正在运行,我将进入下一页。但是,当我返回上一页时,元素的不透明度并未初始化。有人知道为什么吗?

这是我的php代码:

<a href="http://192.168.0.11/next-page/" title="blabla">
   <div class="thumbnail_image_related_project">
      <h2 class="transparent_font">Text and the white background</h2>
      <div id="image">
         <img width="300" height="173" src="http://192.168.0.11/blabla.jpg"/>
      </div>
   </div>
</a>    

这是我的CSS:

    .thumbnail_image_related_project .transparent_font{
    line-height: 1.25em;
    position: absolute;
    top: 0;
    left: 0;
    color: black;
    background-color:white;
    width: 100%;
    height: 100%;
    opacity:0;
}
4

1 回答 1

0

您使用的是 jQuery 还是 jQuery Mobile?我问的原因是在移动设备上,它可能是一个 touchstart 事件而不是悬停。jQuery Mobile 可能会将 touchstart 转换为悬停。

看看这个:jQuery hover event on tag on mobile devices

于 2013-02-13T17:44:19.513 回答