有時使用者可能不知道輸入框要輸入怎樣的值,若能提供一些預設值來提示的話,這樣能讓使用者經驗更好。而 Label In 就是能達到這樣效果的套件。
套件名稱:Label In
套件版本:1.0
作者網站:http://www.ewavetnt.com.au/
套件網址:http://plugins.jquery.com/project/labelIn
發佈日期:2008-06-09
檔案大小:1.63 KB
檔案下載:jquery.labelin.js
參數說明:
檢視原始碼 JavaScript
1 2 3 4 5 6 7 8 9 10 11 | version(選填) 描述: 版本序號(用不到..) 預設值: '1.0' li_class(選填) 描述: 當輸入框失去焦點時所套用的 className 預設值: 'labelIn' attribute(選填) 描述: 當輸入框失去焦點時從指定的屬性來取得顯示的提示字串 預設值: 'name' |
方法說明:
檢視原始碼 JavaScript
1 2 | // 幫指定元素加上 labelIn 效果 $(selector).labelIn([settings]); |
使用範例:
檢視原始碼 JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript" src="jquery.labelin.js"></script> <style type="text/css"> .labelIn { color: #999; } .myBlur { color: #f00; } </style> <script type="text/javascript"> $(function(){ // 幫 #input1 加上提示 $("#input1").labelIn(); // 幫 #text1 加上提示,並自訂 attribute 屬性 $("#text1").labelIn({ attribute: "title" }); // 幫 #input2 加上提示,並自訂 li_class 及 attribute 屬性 $("#input2").labelIn({ li_class: "myBlur", attribute: "title" }); }); </script> <body> <input id="input1" type="text" name="Label" /><br /> <input id="input2" type="text" name="Labe2" title="請輸入學歷" /><br /> <textarea id="text1" name="text1" title="輸入要留言的內容"></textarea> </body> |