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


jQWidgets jqxNavigationBar initContent屬性用法及代碼示例


jQWidgets是一個 JavaScript 框架,用於為 PC 和移動設備製作基於 Web 的應用程序。它是一個非常強大、優化、獨立於平台且得到廣泛支持的框架。這jqxNavigationBar 用於表示具有標題和內容部分的 jQuery 小部件。單擊標題時,內容將相應地展開或折疊。

初始化內容 property 用作回調函數,當項目的內容需要初始化時調用。這裏的索引參數顯示了哪個項目被初始化。

用法:

設置初始化內容 屬性:

$("Selector").jqxNavigationBar({
    initContent: function (index) {
        $("#jqxButton").jqxButton({ 
            $('#jqxbutton_for_initContent')
            .on('click', function () {
                $('#jqx_Navigation_Bar')
                    .jqxNavigationBar('disable');
            }); 
        });
    }
});

返回 初始化內容屬性:

var initContent = 
    $('Selector').jqxNavigationBar('initContent');

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

<link rel=”stylesheet” href=”jqwidgets/styles/jqx.base.css” type=”text/css” />
<script type=”text/javascript” src=”scripts/jquery.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxcore.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxexpander.js”></script>
<script type=”text/javascript” src=”jqwidgets/jqxnavigationbar.js”></script>

例子:下麵的示例說明了 jQWidgets jqxNavigationBar 初始化內容屬性用於禁用導航欄。

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.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxcore.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxexpander.js"> 
    </script> 
    <script type="text/javascript" 
            src="jqwidgets/jqxnavigationbar.js"> 
    </script> 
</head> 
  
<body> 
    <center> 
        <h1 style="color: green;"> 
            GeeksforGeeks 
        </h1> 
        <h3> 
            jQWidgets jqxNavigationBar initContent Property 
        </h3> 
        <div id="jqx_Navigation_Bar" style="margin: 25px;" 
             align="left"> 
            <div>First Header</div> 
            <div> 
                <h8>Content for the first header</h8> 
                <ul> 
                    <li>GFG</li> 
                    <li>CSE</li> 
                </ul> 
            </div> 
            <div> Second Header</div> 
            <div> 
                <input type="button" style="margin: 29px;" 
                       id="jqxbutton_for_initContent"
                       value="Disable"/> 
            </div> 
        </div> 
        <script type="text/javascript"> 
            $(document).ready(function () { 
                $("#jqx_Navigation_Bar"). 
                    jqxNavigationBar({ 
                        width: 250, 
                        height: 132, 
                        initContent: function (index) { 
                            if (index === 0) { 
                                $('#jqxbutton_for_initContent'). 
                                    on('click', function () { 
                                        $('#jqx_Navigation_Bar'). 
                                            jqxNavigationBar( 
                                                'disable'); 
                                    }); 
                            } 
                        } 
                    }); 
                $("#jqxbutton_for_initContent"). 
                    jqxButton({ 
                        width: 100, 
                    }); 
            }); 
        </script> 
    </center> 
</body> 
  
</html>

輸出:

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



相關用法


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