2014-04-02 51 views
0

我使用jQuery的如下樣式我提示工具提示功能和CSS

$(function() { 

     // select all desired input fields and attach tooltips to them 
     $("#tooltips :input").tooltip({ 

     // place tooltip on the right edge 
     position: "center left", 

     // a little tweaking of the position 
     offset: [-2, 10], 

     // use the built-in fadeIn/fadeOut effect 
     effect: "fade", 

     }); 
    }); 

和我的CSS是

#myform { 
    height: auto; 
    } 
    #tooltip{ 
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2); 
    background-color: #fff !important; 
    border: 1px solid !important; 
    border-radius: 5px; 
    border-color: #bbb #bbb #a8a8a8; 
    padding: 16px; 
    z-index: 2000 !important; 
    width: 255px; 
    line-height: 17px; 
    top: 48px; 
    margin-left:-16px !important; 
    font-style: italic; 
    color: #7d7d7d; 
    font-size: 13px; 
    -webkit-transition: all 0.218s; 
    -moz-transition: all 0.218s; 
    -o-transition: all 0.218s; 
    transition: all 0.218s; 
    } 
#tooltip:after { 
     content: ''; 
     position: absolute; 
     border: 3px solid rgba(51, 51, 51, 0.9); 
     border-color: transparent white; 
     border-width: 8px 0 8px 7px; 
     top: 40%; 
     right: -6px; 
} 

#tooltip:before { 
     content: ''; 
     position: absolute; 
     border: 2px solid #333; 
     border-color: transparent #000; 
     border-width: 8px 0 8px 6px; 
     top: 40%; 
     right: -6px; 
} 

我想CSS的名稱更改爲別的,而不是提示,但是當我更改我的CSS名稱時,工具提示不起作用。

任何幫助,將不勝感激

+0

嘗試引導工具提示。其易於使用 http://getbootstrap.com/javascript/#tooltips –

+0

你可以使用任何名稱,而不是#tooltips,例如#mytooltips,但元素名稱應該是相同的 – bitkot

回答

0

相應地更新jQuery選擇器。對於前如果需要將其命名anyRandomName然後

選擇應該是

$("#anyRandomName:input").tooltip({ 
    //... 
}); 

還要確保要在其上顯示tootip有ID爲anyRandomName

0

不知道你正在嘗試的元素問,但是如果你想用CSS中的'test'等任何其他字符串替換'tooltip',那麼你將不得不用$('#test :input')替換$('#tooltip :input')中的相同字符串。

+0

我使用工具提示輸入字段基於以下鏈接http://jquerytools.org/demos/tooltip/form.html 它只適用於.tooltip css沒有其他任何東西 – user3067592

+0

我明白你的觀點。您需要通過jquery.tools.min.js並搜索關鍵字tipClass:「tooltip」並將tipClass:「tooltip」更改爲tipClass:「test」,即您的類的名稱而不是「test」。 –