當前位置: 首頁>>代碼示例 >>用法及示例精選 >>正文


jQWidgets jqxPanel getVScrollPosition()用法及代碼示例


jQWidgets 是一個 JavaScript 框架,用於為 PC 和移動設備製作基於 Web 的應用程序。它是一個非常強大、優化、獨立於平台且得到廣泛支持的框架。 jqxPanel 用於說明 jQuery 麵板小部件,它是不同小部件或元素的支架。此外,它直觀地附加水平和垂直滾動條,以防所述內容不完全可見。

getVScrollPosition()方法用於從顯示的jqxPanel返回垂直滾動條的位置。它不接受任何參數並返回一個數值。

用法:

var position = $("#Selector").jqxPanel('getVScrollPosition');

鏈接文件:下載jQWidgets從給定的鏈接。在 HTML 文件中,找到下載文件夾中的腳本文件。

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery-1.11.1.min.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxbuttons.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxscrollbar.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxpanel.js”></script>  

例子:下麵的例子說明了jqxPanelgetVScrollPosition()jQWidgets 中的方法。

HTML


<!DOCTYPE html> 
<html lang="en"> 
  
<head> 
    <link rel="stylesheet" 
          href="jqwidgets/styles/jqx.base.css" 
          type="text/css" /> 
    <script type="text/javascript" 
            src="scripts/jquery-1.11.1.min.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxbuttons.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxscrollbar.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxpanel.js"> 
    </script> 
</head> 
  
<body> 
    <center> 
        <h1 style="color:green"> 
            GeeksforGeeks 
        </h1> 
  
        <h3>jQWidgets jqxPanel getVScrollPosition() method </h3> 
  
        <div id='jqxp' 
             style="font-size:15px; font-family:Verdana; float:center;"> 
            
            <div style='margin-top:12px;'> 
                <h3>Topics covered by GeeksforGeeks</h3> 
            </div> 
            
            <div style="margin-top:15px; text-align:left;"> 
                <ul> 
                    <li>C Programming</li> 
                    <li>Datastructure</li> 
                    <li>javascript</li> 
                    <li>Algorithm</li> 
                    <li>Python</li> 
                    <li>JQuery</li> 
                    <li>Scala</li> 
                    <li>Java</li> 
                    <li>Html</li> 
                    <li>C++</li> 
                    <li>TOC</li> 
                </ul> 
            </div> 
        </div> 
        <div> 
            <input type="button" id="jqxBtn" 
                style="margin-top:25px" value="Click here" /> 
        </div> 
        <br>       
        <div id="log"></div> 
    </center> 
  
    <script type="text/javascript"> 
        $(document).ready(function () { 
            $("#jqxp").jqxPanel({ 
                width: "200px", 
                height: "170px", 
                theme: 'energyblue' 
            }); 
  
            $("#jqxBtn").jqxButton({ 
                width: "180px", 
                height: "30px", 
                theme: 'energyblue', 
            }); 
            $("#jqxBtn").on("click", function () { 
                $('#jqxp').jqxPanel('scrollTo', 20, 45); 
                var vsp = $('#jqxp').jqxPanel('getVScrollPosition'); 
                $('#log').text("Position of vertical scrollbar: " + vsp); 
            }); 
        }); 
    </script> 
</body> 
</html>

輸出:

參考: https://www.jqwidgets.com/jquery-widgets-documentation/documentation/jqxpanel/jquery-panel-api.htm?search=



相關用法


注:本文由純淨天空篩選整理自nidhi1352singh大神的英文原創作品 jQWidgets jqxPanel getVScrollPosition() Method。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。