jQuery Mobile Navbar创建事件

jQuery Mobile Navbar创建事件

jQuery Mobile是一种基于网络的技术,旨在制作可在所有智能手机、平板电脑和桌面设备上访问的响应式网站和应用程序。

在本教程中,我们将学习jQuery Mobile Navbar的创建事件。创建事件是在创建Navbar widget的时候触发的。每当Navbar被创建时,带有事件和用户界面的回调函数被调用。

语法 。创建事件**回调函数的调用方式如下。

$("#gfgnavbar").navbar({
    create: function (event, ui){}
});
  • 将一个事件监听器绑定到navbarcreate事件上。
$( ".selector" ).on( "navbarcreate",
    function( event, ui ) {} );

CDN链接。为你的jQuery Mobile项目使用以下CDN链接。

<link rel=”stylesheet” href=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css” />
<script src=”https://code.jquery.com/jquery-1.11.1.min.js”></script>
<script src=”https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js”></script>

例子:在下面的例子中,我们使用创建事件,在控制台中记录了一条消息和事件。

<!DOCTYPE html>
<html lang="en">
  
<head>
    <link rel="stylesheet" href=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
    <script src=
"https://code.jquery.com/jquery-1.11.1.min.js">
    </script>
    <script src=
"https://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>
</head>
  
<body>
    <div data-role="page" id="gfgpage">
        <div data-role="header">
            <h1 style="color: green;">
              GeeksforGeeks
            </h1>
        </div>
        <div id="gfgnavbar">
            <ul>
                <li>
                  <a href="#one" 
                       data-icon="cloud">One
                  </a>
                </li>
                <li>
                  <a href="#two" 
                       data-icon="star">Two
                  </a>
                </li>
            </ul>
        </div>
        <div data-role="main" class="ui-content">
            <h3>jQuery Mobile Navbar create Event</h3>
        </div>
          
    </div>
    <script>
        $("#gfgnavbar").navbar({
            create: function (event, ui){
                
                  // Log out a message and the returned event
                console.log(
                  "Welcome to GeeksforGeeks\n", event
                );
            }
        });
    </script>
</body>
  
</html>

输出:

jQuery Mobile Navbar创建事件

jQuery Mobile Navbar创建事件

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程