国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 語言 > JavaScript > 正文

jQuery插件EnPlaceholder實現輸入框提示文字

2024-05-06 16:21:27
字體:
來源:轉載
供稿:網友

EnPlaceholder插件支持密碼框哦!實際對比同類的placeholder插件在ie等瀏覽器下效果要好很多!下面我們來具體探討下此插件的使用方法吧。

用法:

首先在head中分別引入jQuery及本插件

 

 
  1. <script type="text/javascript" src="jquery-1.7.2.min.js">script>  
  2. <script type="text/javascript" src="jquery.enplaceholder.js">script>  

然后就可以調用鳥

 

 
  1. //通過value模擬placeholder  
  2. $('input').placeholder();  
  3. //通過插入元素模擬placeholder  
  4. $('input').placeholder({isUseSpan:true});  

代碼:

 

 
  1. <script type="text/javascript" src="/demo/js/jquery.min.js"></script><script type="text/javascript" src="/demo/js/38/jquery.enplaceholder.js"></script> 
  2. <style type="text/css"
  3. body { font: 12px/1.5 'simsun'; } 
  4. form { width: 420px; height: 260px; margin: 20px auto 0; } 
  5. h3 { font-weight: bold; margin: 10px 0; } 
  6. p { margin-bottom: 10px; } 
  7. input { vertical-align: middle; margin-left: 10px; height: 24px; line-height: 24px; width: 200px; padding-left: 2px; } 
  8. textarea { vertical-align: middle; margin-left: 10px; width: 200px; height: 50px; font: inherit; padding-left: 2px; } 
  9. .wrap-statistics { visibility: hidden; } 
  10. html{color:#000;background:#fff;} 
  11. body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,form,input,textarea,p,th,td,hr,button{margin:0;padding:0;} 
  12. body,button,input,select,textarea{font:12px/1.5 tahoma,arial;} 
  13. input,select,textarea{font-size:100%;} 
  14. table{border-collapse:collapse;border-spacing:0;} 
  15. th{text-align:inherit;} 
  16. img{border:0;} 
  17. iframe{display:block;} 
  18. em,th{font-style:normal;font-weight:500;} 
  19. ol,ul {list-style:none;} 
  20. h1,h2,h3,h4,h5,h6{font-size:100%;font-weight:500;} 
  21. a{text-decoration:none;} 
  22. a:hover{text-decoration:underline;} 
  23.  
  24. .fn-clear{zoom:1;} 
  25. .fn-clear:after{visibility:hidden;display:block;font-size:0;content:".";clear:both;height:0;} 
  26. .fn-hide{display:none;} 
  27. .fn-left,.fn-right{display:inline;} 
  28. .fn-left{float:left;} 
  29. .fn-right{float:right;} 
  30. .fn-hide-text{font-size:0;line-height:0;color:rgba(0,0,0,0);} 
  31. .sl-wrap,.sl-wrap td,.sl-wrap th{word-wrap:break-word;word-break:break-all;}  
  32. .sl-wrap-table{ table-layout:fixed; }</style> 
  33. <form id="form1"
  34. <h3>通過value方式模擬placeholder</h3> 
  35. <p>$('#form1 input,#form1 textarea').placeholder();</p> 
  36. <p><label for="username1">用戶名:</label> <input id="username1" name="username1" placeholder="請輸入用戶名" required="" type="text" value="" /></p> 
  37. <p><label for="address1">地 址:</label> <input id="address1" name="address1" placeholder="請輸入地址" required="" type="text" value="" /></p> 
  38. <p><label for="remarks1">備 注:</label></p> 
  39. </form> 
  40. <form id="form2"
  41. <h3>在不支持placeholder的瀏覽器下,通過插入懸浮的span元素方式模擬</h3> 
  42. <h4>文本框內容改變時placeholder消失:</h4> 
  43. <p>$('#username2,#password').placeholder({isUseSpan:true});</p> 
  44. <p><label for="username2">用戶名:</label> <input id="username2" name="username1" placeholder="請輸入用戶名" required="" type="text" value="" /></p> 
  45. <p><label for="password">密 碼:</label> <input id="password" name="password" placeholder="請輸入密碼" required="" type="password" value="" /></p> 
  46. <p><label for="remarks2">備 注:</label></p> 
  47. <h4>獲得焦點時placeholder消失:</h4> 
  48. <p>$('#address2').placeholder({isUseSpan:true,onInput:false});</p> 
  49. <p><label for="address2">地 址:</label> <input id="address2" name="address1" placeholder="請輸入地址" required="" type="text" value="" /></p> 
  50. </form> 
  51. <script> 
  52. $('#form1 input,#form1 textarea').placeholder(); 
  53. $('#username2,#password').placeholder({isUseSpan:true}); 
  54. $('#address2').placeholder({isUseSpan:true,onInput:false}); 
  55. $('#remarks2').placeholder({isUseSpan:true}); 
  56. </script> 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表

圖片精選

主站蜘蛛池模板: 内江市| 桑日县| 太和县| 赤水市| 新巴尔虎右旗| 岑巩县| 西贡区| 仙桃市| 永修县| 平定县| 吴川市| 吴江市| 山东省| 桐梓县| 定兴县| 江达县| 巴东县| 迭部县| 新野县| 乳源| 马山县| 塘沽区| 酒泉市| 高碑店市| 洞口县| 普兰县| 丰原市| 喀什市| 乃东县| 淄博市| 高碑店市| 阿克陶县| 伊宁县| 苍山县| 鄂伦春自治旗| 邯郸市| 巴彦县| 双峰县| 重庆市| 西贡区| 宁明县|