jQuery Tools tooltip使用说明 |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
本文标签:tooltip HTML 复制代码 代码如下: <!DOCTYPE html> <html> <head> <title>jQuery Tools standalone demo</title> <!-- include the Tools --> <script src="http://cdn.jquerytools.org/1.2.7/full/jquery.tools.min.js"></script> <link rel="stylesheet" type="text/css" href="./tooltip-generic.css"/> <style> #myform { border:1px outset #ccc; background:#fff repeat-x; padding:20px; margin:20px auto; width:350px; font-size:12px; -moz-border-radius:4px; } #myform h3 { text-align:center; margin:0 0 10px 0; } /* http://www.quirksmode.org/css/forms.html */ #inputs label, #inputs input, #inputs textarea, #inputs select { display: block; width: 150px; float: left; margin-bottom: 20px; } #inputs label { text-align: right; width: 75px; padding-right: 20px; } #inputs br { clear: left; } </style> </head> <body><form id="myform" action="#"> <h3>Registration Form</h3> <div id="inputs"> <!-- username --> <label for="username">Username</label> <input id="username" title="Must be at least 8 characters."/> <br /> <!-- password --> <label for="password">Password</label> <input id="password" type="password" title="Make it hard to guess." /> <br /> <!-- email --> <label for="email">Email</label> <input id="email" title="We wont send you any marketing material." /> <br /> <!-- message --> <label for="body">Message</label> <textarea id="body" title="Whats on your mind?"></textarea> <br /> <!-- message --> <label for="where">Select one</label> <select id="where" title="Select one of these options"> <option>-- first option --</option> <option>-- second option --</option> <option>-- third option --</option> </select> <br /> </div> <!-- email --> <label> I accept the terms and conditions <input type="checkbox" id="check" title="Required to proceed" /> </label> <p> <button type="button" title="This button wont do anything"> Proceed </button> </p> </form> <!-- javascript coding --> <script> // execute your scripts when the DOM is ready. this is a good habit $(function() { // select all desired input fields and attach tooltips to them $("#myform :input").tooltip({ // place tooltip on the right edge position: "center right", // a little tweaking of the position offset: [-2, 10], // use the built-in fadeIn/fadeOut effect effect: "fade", // custom opacity setting opacity: 0.7 }); }); </script> </body> </html> CSS 复制代码 代码如下: /* simple css-based tooltip */ .tooltip { background-color:#000; border:1px solid #fff; padding:10px 15px; width:200px; display:none; color:#fff; text-align:left; font-size:12px; /* outline radius for mozilla/firefox only */ -moz-box-shadow:0 0 10px #000; -webkit-box-shadow:0 0 10px #000; } CSS可以不需要,这样显示的样子恶心了点 。 关键代码: 复制代码 代码如下: // select all desired input fields and attach tooltips to them $("#myform :input").tooltip({ // place tooltip on the right edge position: "center right", // a little tweaking of the position offset: [-2, 10], // use the built-in fadeIn/fadeOut effect effect: "fade", tipClass:tooltip, // 省却值:tooltip,少了这一行效果也是一样 // custom opacity setting opacity: 0.7 }); 使用 这里是可能存在的最简单的工具提示的初始化: $("#myform :input").tooltip();配置
确保你已经阅读 大约 事件 jQuery工具 。 所有事件监听器接收 这个 事件 对象 作为第一个参数 。
复制代码 代码如下: $("label").tooltip({ // change trigger opacity slowly to 0.8 onShow: function() { this.getTrigger().fadeTo("slow", 0.8); } }); 事件管理 jQuery工具提示可以让你完全控制 当 工具提示 将显示或隐藏 。 您可以指定不同的事件 不同类型的元素 。 你可以控制这种行为 这个 事件 配置变量,它具有以下 默认值: 复制代码 代码如下: events: { def: "mouseenter,mouseleave", // default show/hide events for an element input: "focus,blur", // for all input elements widget: "focus mouseenter,blur mouseleave", // select, checkbox, radio, button tooltip: "mouseenter,mouseleave" // the tooltip element } 脚本 api 首先确保你已经了解你自己 与 jQuery工具 脚本 。 以下列出的是所有API方法:
内置的效果“渐”有它自己的一组配置选项 如下:
下面有个自定义事件的例子:http://jquerytools.org/demos/tooltip/custom-effect.htm tab:传送门 tab(幻灯片):传送门 tooltip:传送门 overlay:传送门 dateinput:传送门 在携程做着framework2.0,研究的却是framework4.0,当时是怎么想的T.T 。全是TMD老技术和堆代码 |