Focus on DIV

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
        <script src="http://code.jquery.com/jquery-1.11.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(
            function () {
                $('html, body').animate({ scrollTop: ($("#DivContent2").offset().top - 100) }, 'slow');
            });

        function clickwithbtn()
        {
            $('html, body').animate({ scrollTop: ($("#DivContent2").offset().top - 100) }, 'slow');
        };
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <div><input type="button" value="Click" onclick="clickwithbtn()" id="btnClick" /> </div>
      <div id="DivContent1" style="height:1300px; width:600px;">
          scroll to element with jQuery
      </div>
    <div id="DivContent2" style="height:1200px;width:600px;">
        focus to div is working
    </div>
    </div>
    </form>
</body>
</html>

Next PostNewer Post Previous PostOlder Post Home

0 comments:

Post a Comment