search

Home  >  Q&A  >  body text

javascript - The div is a link. When the mouse is moved up, a div will appear, such as a view more button. How to do this?

p is a link. If you move the mouse up, a p will appear, such as a view more button. How to do this?

怪我咯怪我咯2732 days ago888

reply all(4)I'll reply

  • typecho

    typecho2017-07-05 10:42:58

    Just listen to the mouseenter event and then display the p or button

    reply
    0
  • PHP中文网

    PHP中文网2017-07-05 10:42:58

    Use css for hover

    reply
    0
  • 伊谢尔伦

    伊谢尔伦2017-07-05 10:42:58

    /* 1.css */
    .more{display:none};
    p:hover .more{display:block}
    //2.js
    $('p').hover(function(){
    $('.more').show();
    })

    http://jsbin.com/tiqenecata/e...

    reply
    0
  • 欧阳克

    欧阳克2017-07-05 10:42:58

    html:
    <p>

    <p class="a">假如我是一个链接</p>
    <p class="b">点我查看更多</p>

    <p>

    js (load jQuery library):

    $(function(){

        $(".b").css("display","none");      //初始化隐藏按钮
        $(".a").hover(function(){           //鼠标移入移出函数
            $(".b").css("dispaly","block")  //移入显示
        },function(){    
            $(".b").css("dispaly","none")   //移出隐藏
        })  
    

    })

    reply
    0
  • Cancelreply