jquery提示外掛程式qtip2使用(全面),jquery提示外掛程式qtip2
詳情參考:http://qtip2.com
我下載的 庫檔案以及自己總結的資料:連結:http://pan.baidu.com/s/1pJI43Cv密碼:751y
基本用法:(1)只有簡單提示$('#username').qtip({ // Grab some elements to apply the tooltipto content: { text: '使用者名稱只能輸入英文字母或者數字' }});
(2)帶標題的
$('#password').qtip({ // Grabsome elements to apply the tooltip to content: { text:'密碼為6-12位元',title:"示範", }
(3)設定位置
$('#password').qtip({ // Grab some elements to apply the tooltipto content: { text: '密碼為6-12位元',title:"示範", },position:{ my: 'top left', at: 'bottom center',},style:{ classes: 'qtip-purple', tip: { border:1, width:50, height:20 }}});
my:是指三角的位置at:是在提示在組件的相對位置(top 上 bottom下 )( left左 right右center中)兩組配合使用
(4)設定風格
$('#password').qtip({ // Grab someelements to apply the tooltip to content: { text: '密碼為6-12位元',title:"示範", },position:{ my: 'top left', at: 'bottom center',},style:{ classes: 'qtip-purple', tip: { border:1, width:50, height:20 }}}); classes可以有多種選擇
qtip-light淺色qtip-dark 深色
qtip-cream
qtip-red
qtip-blue
qtip-shadow
qtip-rounded圓角
qtip-youtube
qtip-jtools
qtip-cluetip
qtip-tipsy
qtip-tip
qtip-titlebar
qtip-default
classes:'qtip-purple',
classes: 'qtip-purpleqtip-rounded',
可以自訂 上面的qtip-purple就是我自己定義的
.qtip-purple{background-color:#9FF0E1;border-color:#EEC933;color:#42B453}.qtip-purple.qtip-titlebar{background-color:#9465E1}
background-color是內容的背景顏色border-color:整個的邊框color:文字的顏色.qtip-purple.qtip-titlebar{background-color: #9465E1} 設定的是標題的背景色
標題還可以設定標題文字顏色
.qtip-purple .qtip-titlebar{background-color:#9465E1;color:red}
(6)顯示 隱藏 重設等
顯示:$('#username').qtip('show');
隱藏:$('#username').qtip('hide');
$('.selector').qtip('reposition');// Reposition all tooltips belonging to the selected elements重設該選取器選中元素的提示組件
$('.selector').qtip('disable');// Disable all tooltips belonging to the selectedelements
該選取器選中元素的提示組件設為不可用狀態
$('.selector').qtip('toggle',true);// 顯示該選取器選中元素的提示組件$('.selector').qtip('destroy',true);// 直接銷毀屬於該選取器選中元素的提示組件
(7)修改值
$(“#username”).qtip('api').set('content.text','這裡是內容');
$(“#username”).qtip('api').set('content.text','這裡是修改後的內容')..set('content.title','這裡是修改後的標題');