1

I am having a hard time trying to insert jquery code inside my PHP file. This is what I have so far.

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

This particular code is what I want to fade in when user scrolls down.

1
  • You should describe problem elaborately. What you really want, what portion can you complete... Commented Jun 15, 2017 at 4:03

2 Answers 2

2

It's nothing to do with PHP, you can treat it with HTML as usual. So, you don't need to "insert" into 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>

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you! That helps a lot!
0

Inside your php file

<script>

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

</script>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.