在PHP文件中添加jquery

时间:2017-06-15 04:00:13

标签: php jquery

我很难在我的PHP文件中插入jquery代码。这是我到目前为止所做的。

</div>
<!-- left -->
<div class="col-lg-6 col-md-6">
  <div id="rightside">
    <img src="images/about/ab1.jpg" style="margin-left: 30px;">
  </div>

当用户向下滚动时,我想要淡出这个特殊代码。

2 个答案:

答案 0 :(得分:1)

这与PHP无关,您可以照常使用HTML处理它。 因此,您不需要“插入”PHP。

<html>
    <head>
        <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
        <script>
            $(document).ready(function () {
                $(window).scroll(function () {
                    $("#rightside").fadeOut();
                });
               
            });
        </script>
    </head>
    <body>
        <div id="rightside">
            <img src="images/about/ab1.jpg" style="margin-left: 30px;">
        </div>

       
    </body>
</html>

答案 1 :(得分:0)

在你的php文件中

<script>

    var lastScrollTop = 0;
    $(window).scroll(function(event){
       var st = $(this).scrollTop();
       if (st > lastScrollTop){
           $('img').fadeIn();
       }
       lastScrollTop = st;
    });

</script>