Setting id and adding CSS class to Poshy Tip tooltip div

喜欢而已 提交于 2019-12-12 02:29:50

问题


How do I set the id or add an extra CSS class to a tooltip div created with Poshy Tip? I'd like to be able to distinguish between different tooltips that are displayed at the same time.

I've tried adding the extra CSS class in the initialization of the tooltip, but this breaks the layout as there is some CSS generated on the fly by Poshy Tip that stops functioning correctly. The plugin provides no option to set the id:

$('#tip').poshytip({
    className: 'tip-yellow',
    // Replacing the previous line with the next one breaks the layout:
    // className: 'tip-yellow extraClass',
    // This option doesn't exist:
    // id: 'myId',
    ...
}

See this fiddle.

Can we add extraClass and set myId after initialization?

My jQuery skills are limited, so chances are I'm simply overlooking something.


回答1:


I couldn't get the text-decoration to work but I did change the color:

I commented out classname: 'tip-yellow'

and added this at the bottom:

$('.tip-yellow:last').addClass('extraClass');

Your Fiddle v2

UPDATE: add ID to it as well

Your Fiddle v3



来源:https://stackoverflow.com/questions/18064316/setting-id-and-adding-css-class-to-poshy-tip-tooltip-div

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!