本文实例讲述了一款轻量级的表单提示插件---jQuery Form Toolltip。分享给大家供大家参考。具体如下:
jQuery Form Toolltip 特点:
- 你可以单独自定义提示信息的CSS样式。
- 你可以指定淡入淡出的方向,当前支持Top, Bottom, Right 和 Left
运行效果截图如下:

具体代码如下:
jquery实例:jQuery Form Toolltip使用方法
引入核心文件
1 2 | <script src= "js/jquery/2.1.1/jquery.min.js" ></script>
<script src= "src/jquery.formtooltip.js" ></script>
|
登录后复制
构建html
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <form id= "formname" >
<table>
<tr>
<td> Title </td>
<td><input type= "text" value= "blank" name= "title" /></td>
</tr>
<tr>
<td> Name </td>
<td><input type= "name" value= "Blank Name" name= "name" /></td>
</tr>
<tr>
<td> Color </td>
<td><input type= "color" value= "#000FFF" name= "color" /></td>
</tr>
<tr>
<td> TextArea </td>
<td><textarea type= "month" value= "" name= "text" ></textarea></td>
</tr>
</table>
</form>
|
登录后复制
写入JS初始化
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | $(document).ready( function (){
var fields = {
title: {
tooltip : "This field is actually for bla bla bla...</br>and bla bla bla" ,
position: 'bottom'
},
name : {
tooltip: "This is for fun!!!!" ,
position: 'right' ,
backgroundColor: "#FF0000" ,
color: '#FFFF00'
},
color : {
tooltip: "This is for your cover color~~~<a href='#'>here</a>"
},
text : {
tooltip: "Please provide your comment here."
}
};
$( "#formname" ).formtoolip(fields, { backgroundColor: "#000000" , color : "#FFFFFF" , fontSize : 15, padding : 10, borderRadius : 5});
});
|
登录后复制
定义fields数组,把需要提示的表单字段依次写入,然后调用formatoolip函数初始化。
以上就是为大家分享的jQuery表单提示插件:jQuery Form Toolltip ,很实用,希望大家喜欢。