jQuery 모바일 양식 입력
jQuery Mobile 양식 입력 요소
jQuery 모바일 텍스트 입력 상자
입력 필드는 표준 HTML 요소를 통해 인코딩되며, jQuery Mobile은 모바일 장치에서 더 쉽게 사용할 수 있도록 스타일을 추가합니다. 새로운 HTML5 <input> 유형을 사용할 수도 있습니다.
Instance
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>文本输入</h1> </div> <div data-role="main" class="ui-content"> <form method="post" action="demo_form.php"> <div class="ui-field-contain"> <label for="fullname">全名:</label> <input type="text" name="fullname" id="fullname"> <label for="bday">生日:</label> <input type="date" name="bday" id="bday"> <label for="email">E-mail:</label> <input type="email" name="email" id="email" placeholder="你的电子邮箱.."> </div> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
Run Instance»
온라인 예제를 보려면 "인스턴스 실행" 버튼을 클릭하세요
팁:자리 표시자를 사용하세요. 지정하려면 입력 필드의 예상 값을 설명하는 간단한 설명:
<input placeholder="sometext">
Text Area
여러 줄 텍스트 입력의 경우 <textarea>를 사용하세요.
참고: 텍스트를 입력하면 새로 추가된 줄에 맞게 텍스트 필드의 크기가 자동으로 조정됩니다.
Example
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>文本框</h1> </div> <div data-role="main" class="ui-content"> <form method="post" action="demoform.php"> <div class="ui-field-contain"> <label for="info">附加信息:</label> <textarea name="addinfo" id="info"></textarea> </div> <input type="submit" data-inline="true" value="提交"> </form> <p><b>注意:</b> 文本框会根据你的输入自动调整文本框的高度,你可以在以上文本框输入内容,查看效果。</p> </div> </div> </body> </html>
예제 실행»
온라인 예제를 보려면 "예제 실행" 버튼을 클릭하세요
검색 입력 상자
type="search" 유형 입력 상자는 HTML5의 새로운 기능입니다. 입력 검색을 위한 텍스트 필드를 정의하는 것입니다:
Instances
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="main" class="ui-content"> <form method="post" action="demoform.asp"> <div class="ui-field-contain"> <label for="search">搜索:</label> <input type="search" name="search" id="search" placeholder="搜索内容..."> </div> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
Run Instance»
온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요.
라디오 버튼
사용자가 제한된 수의 선택에 있을 때 옵션을 하나만 선택할 때는 라디오 버튼을 사용하세요.
일련의 라디오 버튼을 만들려면 type="radio"인 입력과 해당 라벨을 추가하세요. <fieldset> 요소 내에서 라디오 버튼을 둘러쌉니다. <fieldset>의 제목을 정의하기 위해 <legend> 요소를 추가할 수도 있습니다.
팁: 버튼을 그룹화하려면 data-role="controlgroup"을 사용하세요.
Instance
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="main" class="ui-content"> <form method="post" action="demoform.php"> <fieldset data-role="controlgroup"> <legend>请选择您的性别:</legend> <label for="male">男性</label> <input type="radio" name="gender" id="male" value="male"> <label for="female">女性</label> <input type="radio" name="gender" id="female" value="female"> </fieldset> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
인스턴스 실행»
온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요
체크박스
사용자가 제한된 수의 선택 사항 중에서 하나 이상의 옵션을 선택할 때 체크박스를 사용하세요.
Instances
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>复选框</h1> </div> <div data-role="main" class="ui-content"> <form method="post" action="demoform.php"> <fieldset data-role="controlgroup"> <legend>请选择您喜爱的颜色:</legend> <label for="red">红色</label> <input type="checkbox" name="favcolor" id="red" value="red"> <label for="green">绿色</label> <input type="checkbox" name="favcolor" id="green" value="green"> <label for="blue">蓝色</label> <input type="checkbox" name="favcolor" id="blue" value="blue"> </fieldset> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
Run Instance»
온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요.
더 많은 예
라디오 버튼이나 체크박스를 가로로 그룹화하려면 data-type="horizontal"을 사용하세요.
예제
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>单选按钮和复选框</h1> </div> <div ddata-role="main" class="ui-content"> <form method="post" action="demoform.php"> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>请选择您的性别:</legend> <label for="male">男性</label> <input type="radio" name="gender" id="male" value="male"> <label for="female">女性</label> <input type="radio" name="gender" id="female" value="female"> </fieldset> <fieldset data-role="controlgroup" data-type="horizontal"> <legend>请选择您喜爱的颜色:</legend> <label for="red">红色</label> <input type="checkbox" name="favcolor" id="red" value="red"> <label for="green">绿色</label> <input type="checkbox" name="favcolor" id="green" value="green"> <label for="blue">蓝色</label> <input type="checkbox" name="favcolor" id="blue" value="blue"> </fieldset> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
인스턴스 실행»
온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요.
또한 <fieldset>을 필드 컨테이너로 묶을 수도 있습니다:
Instance
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>单选按钮和复选框</h1> </div> <div data-role="main" class="ui-content"> <form method="post" action="demoform.php"> <div data-role="fieldcontain"> <fieldset data-role="controlgroup"> <legend>请选择您的性别:</legend> <label for="male">男性</label> <input type="radio" name="gender" id="male" value="male"> <label for="female">女性</label> <input type="radio" name="gender" id="female" value="female"> </fieldset> </div> <div data-role="fieldcontain"> <fieldset data-role="controlgroup"> <legend>请选择您喜爱的颜色:</legend> <label for="red">红色</label> <input type="checkbox" name="favcolor" id="red" value="red"> <label for="green">绿色</label> <input type="checkbox" name="favcolor" id="green" value="green"> <label for="blue">蓝色</label> <input type="checkbox" name="favcolor" id="blue" value="blue"> </fieldset> </div> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
인스턴스 실행»
온라인 예제를 보려면 "예제 실행" 버튼을 클릭하세요.
버튼 중 하나를 미리 확인하려면 HTML에서 <input>의 확인 속성을 사용하세요.
Example
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>单选按钮和复选框</h1> </div> <div data-role="main" class="ui-content"> <form method="post" action="demoform.asp"> <fieldset data-role="controlgroup"> <legend>请选择您的性别:</legend> <label for="male">Male</label> <input type="radio" name="gender" id="male" value="male" checked> <label for="female">Female</label> <input type="radio" name="gender" id="female" value="female"> </fieldset> <fieldset data-role="controlgroup"> <legend>请选择您喜爱的颜色:</legend> <label for="red">红色</label> <input type="checkbox" name="favcolor" id="red" value="red" checked> <label for="green">绿色</label> <input type="checkbox" name="favcolor" id="green" value="green"> <label for="blue">蓝色</label> <input type="checkbox" name="favcolor" id="blue" value="blue" checked> </fieldset> <input type="submit" data-inline="true" value="提交"> </form> </div> </div> </body> </html>
예제 실행»
온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 클릭하세요.
팝업 창에 양식을 넣을 수 있습니다:
Instance
<!DOCTYPE html> <html> <head> <meta name="viewport" content="width=device-width, initial-scale=1"> <link rel="stylesheet" href="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.css"> <script src="http://apps.bdimg.com/libs/jquery/1.10.2/jquery.min.js"></script> <script src="http://apps.bdimg.com/libs/jquerymobile/1.4.5/jquery.mobile-1.4.5.min.js"></script> </head> <body> <div data-role="page"> <div data-role="header"> <h1>欢迎访问我的主页</h1> </div> <div data-role="main" class="ui-content"> <a href="#myPopup" data-rel="popup" class="ui-btn ui-btn-inline ui-corner-all ui-icon-check ui-btn-icon-left">弹窗中使用表单</a> <div data-role="popup" id="myPopup" class="ui-content" style="min-width:250px;"> <form method="post" action="demoform.php"> <div> <h3>登录信息</h3> <label for="usrnm" class="ui-hidden-accessible">用户名:</label> <input type="text" name="user" id="usrnm" placeholder="用户名"> <label for="pswd" class="ui-hidden-accessible">密码:</label> <input type="password" name="passw" id="pswd" placeholder="密码"> <label for="log">保存登录</label> <input type="checkbox" name="login" id="log" value="1" data-mini="true"> <input type="submit" data-inline="true" value="登录"> </div> </form> </div> </div> <div data-role="footer"> <h1>底部文本</h1> </div> </div> </body> </html>
인스턴스 실행»
을 클릭하세요. 온라인 인스턴스를 보려면 "인스턴스 실행" 버튼을 누르세요