Question

I have a href tag in reply.php file

<a id="click" href="javascript:replytoQuestion('<?=$comment_id?>')">Answer <?=htmlentities($row['studentname'])?> </a>

Then I have a form in index.php file

<form id="answerForm"

When user click Answer in href tag page must scroll to form id="answerForm

I tried to use this:

<script>
    $(document).ready(function (){
        $("#click").click(function (){
            //$(this).animate(function(){
                $('html, body').animate({
                    scrollTop: $("#answer").offset().top
                }, 2000);
            //});
        });
    });
</script>

but it does not work.

Any suggestions

Was it helpful?

Solution

Happy that it worked, my idea was pretty simple :

function replytoQuestion(numberId, idName) {
     var numberId; // Number id
     // *** Some treatment with numberId *** //
     return go(idName);
}

function go(idName) {
    // *** scroll to the div with smootheffect *** //
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top