【问题标题】:Javascript for a suggestion box that pops up as the user scrolls down the screen. [closed]用户向下滚动屏幕时弹出的建议框的 Javascript。 [关闭]
【发布时间】:2015-02-17 18:18:00
【问题描述】:

我正在尝试为 wordpress 网站构建一个 Ajax sn-p,当用户向下滚动屏幕时,该网站会弹出并建议该类别的下一篇博客文章。是否有任何可用的 jQuery 插件或者我应该从哪里开始?

【问题讨论】:

    标签: javascript jquery ajax wordpress


    【解决方案1】:

    您不需要插件。试试这样的 jQuery:

    $(document).ready(function() {
    
      //Check to see if the window is top if not then display button
      $(window).scroll(function() {
        if ($(this).scrollTop() > 100) {
          $('.nextPost').fadeIn();
        } else {
          $('.nextPost').fadeOut();
        }
      });
    });
    .nextPost {
      background: lightgray;
      font-weight: bold;
      position: fixed;
      top: 5px;
      right: 5px;
      display: none;
    }
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
    <div class="nextPost">Next Post</div>
    
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>
    <br/>

    【讨论】:

    • 这很棒。我会试试看。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-09-18
    • 1970-01-01
    • 2021-11-19
    • 2021-08-23
    • 1970-01-01
    • 2020-12-06
    • 1970-01-01
    相关资源
    最近更新 更多