如何使用jQuery Mobile创建一个弹出表单

如何使用jQuery Mobile创建一个弹出表单

jQuery Mobile是一种基于网络的技术,用于制作可在所有智能手机、平板电脑和台式机上访问的响应式内容。在这篇文章中,我们将使用jQuery Mobile创建一个表单弹出窗口。

方法:添加你的项目所需的jQuery Mobile脚本。

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

例子:我们将在一个弹出式窗口内创建一个表单。当我们点击按钮时,它会打开一个表单。

<!DOCTYPE html>
<html>
  
<head>
    <link rel="stylesheet" href=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
  
    <script src=
        "http://code.jquery.com/jquery-1.11.1.min.js">
    </script>
  
    <script src=
"http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js">
    </script>
</head>
  
<body>
    <center>
        <h1>GeeksforGeeks</h1>
  
        <h4>
            Design Form popup using jQuery Mobile
        </h4>
  
        <a href="#FormDesign" data-rel="popup" 
            data-position-to="window"
            class="ui-btn ui-corner-all ui-shadow 
            ui-btn-inline ui-icon-check 
            ui-btn-icon-left ui-btn-a"
            data-transition="pop">Form
        </a>
          
        <div data-role="popup" id="FormDesign" 
            data-theme="a" class="ui-corner-all">
              
            <form>
                <div style="padding:10px 20px;">
                    <h3>GeeksforGeeks Login Form</h3>
  
                    <label for="un" class="ui-hidden-accessible">
                        First Name:
                    </label>
                      
                    <input type="text" name="user" id="un" value="" 
                        placeholder="Enter First Name" data-theme="a">
  
                    <label for="un" class="ui-hidden-accessible">
                        Last Name:
                    </label>
                      
                    <input type="text" name="user" id="un" value=""
                        placeholder="Enter Last Name" data-theme="a">
  
                    <label for="un" class="ui-hidden-accessible">
                        Username:
                    </label>
                      
                    <input type="text" name="user" id="un" value=""
                        placeholder="Enter Username" data-theme="a">
  
                    <label for="pw" class="ui-hidden-accessible">
                        Password:
                    </label>
                      
                    <input type="password" name="pass" id="pw" value=""
                        placeholder="Enter Password" data-theme="a">
  
                    <label for="pw" class="ui-hidden-accessible">
                        Confirm Password:
                    </label>
                      
                    <input type="password" name="pass" id="pw" 
                        value="" placeholder="Enter Confirm Password"
                        data-theme="a">
  
                    <button type="submit"
                        class="ui-btn ui-corner-all ui-shadow 
                        ui-btn-b ui-btn-icon-left ui-icon-check">
                        Sign UP
                    </button>    
                </div>
            </form>
        </div>
    </center>
</body>
  
</html>

输出:

如何使用jQuery Mobile创建一个弹出表单?

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程