【问题标题】:Show and hide div using JavaScript?使用 JavaScript 显示和隐藏 div?
【发布时间】:2013-05-27 10:03:31
【问题描述】:

my fiddle

        $szPostContent = $post->post_content;
        $szSearchPattern = '#(<img.*?>)#';
        $a='';
        $aPics='';
        preg_match_all( $szSearchPattern, $szPostContent, $aPics );
        $iNumberOfPics = count($aPics);
        echo "<br />Number of pics on each post...............".$iNumberOfPics;
        array_push($postimg, $iNumberOfPics);

$iNumberofPics 显示来自单个帖子的图像... 查看演示 ..u 会发现在箭头 img 鼠标悬停时,滑块消失。而我想连续显示主 div,直到用户留在该页面上..

【问题讨论】:

  • @Spokey -- 感谢您的回复,但我想显示 imageslider div 和两个箭头类,并且在 imageslider div 的 mouseout 上我想隐藏该 imageslider div

标签: php javascript jquery html


【解决方案1】:
<div class='container' style='height:150px; width:225px;'>
    <div class="imageslider" id="imageslider" style="border: 1px solid #000000; height:150px; width:225px;display:none">
        <img class="arrow left" style="border: 1px solid #000000; height:25px; width:25px; float:left; margin-top:50px;" />
        <div class="images"></div>
        <img class="arrow right" style="border: 1px solid #000000; height:25px; width:25px; float:right; margin-top:50px;" />
    </div>

还有脚本

$(".container").hover(function () {
    $(this).find('.imageslider').show();
}, function () {
    $(this).find('.imageslider').hide();
});

FIDDLE

.container 是一个占位符,以便您能够将鼠标悬停在上面

【讨论】:

    【解决方案2】:

    我不确定我的问题是否正确,因此我希望以下方法之一对您有所帮助: 在您的代码中,您使用 onmouseout,而不是 onmouseover。你可以:

    • 在鼠标悬停和鼠标悬停时使用 $(...).show() 和 $(...).hide()。
    • 看一下 $(...).toggle() ,它会带走一些工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-04
      • 2014-01-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多