首页 > 代码库 > jquery中:input和input的区别分析

jquery中:input和input的区别分析

:input表示选择表单中的input,select,textarea,button元素,input仅仅选择input元素。

<html>    <head>        <style>            .focus{                background-color: blue            }        </style>    </head>    <body>        <script type="text/javascript" src="scripts/jquery.1.6.1.min.js"></script>        <script type="text/javascript">         $(function(){             $(":input").focus(function(){                 $(this).addClass("focus");             }).blur(function(){                 $(this).removeClass("focus");             });         })        </script>         <form action="" method="post" id="regForm">         <fieldset>             <legend>Personal Info</legend>             <div>                 <label for="username">Name:</label>                 <input id="username" type="text" />             </div>             <div>                 <label for="pass">Password:</label>                 <input id="pass" type="password" />             </div>             <div>                 <label for="msg">Detail Information:</label>                 <textarea id="msg" rows="2" cols="20"></textarea>             </div>             <div>                <select name="single">                    <option>Single</option>                    <option>Single2</option>                </select>            </div>            <div>                <select name="multiple" multiple="multiple">                    <option selected="selected">Multiple</option>                    <option>Multiple2</option>                    <option selected="selected">Multiple3</option>                </select>            </div>        </fieldset>     </body></html>

 

http://www.jb51.net/article/27688.htm

jquery中:input和input的区别分析