gpt4 book ai didi

php - JQUERY ToolTip - 特定词的样式

转载 作者:行者123 更新时间:2023-11-28 13:07:28 25 4
gpt4 key购买 nike

我有这个jquery:

this.tooltip = function(){  
/* CONFIG */
xOffset = 10;
yOffset = 20;
// these 2 variable determine popup's distance from the cursor
// you might want to adjust to get the right result
/* END CONFIG */
$("a.tooltip").hover(function(e){
this.t = this.title;
this.title = "";
$("body").append("<p id='tooltip'>"+ this.t +"</p>");
$("#tooltip")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},
function(){
this.title = this.t;
$("#tooltip").remove();
});
$("a.tooltip").mousemove(function(e){
$("#tooltip")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px");
});
};



// starting the script on page load
$(document).ready(function(){
tooltip();
});

它与名为“tooltip”的 CSS 类一起使用,该类具有 font-variant:small-caps;

所有工具提示都采用小型大写字母,看起来很棒 :)

工具提示是这样调用的: <a href="#" class="tooltip" title="this is the tooltip">hover to see tooltip</a>

我想在工具提示中有一个或两个单词 BOLD 并且全部小写..我怎样才能做到这一点而不影响工具提示的重置?

所以不要显示为:

这是工具提示

我愿意:

这是工具提示

有什么想法吗??

最佳答案

您可以将某个类添加到要添加的文本中,然后通过 CSS 对其进行样式设置。例如

$("a.tooltip").hover(function(e){                                             
this.t = this.title;
this.title = "";
$("body").append("<p id='tooltip' class='tooltipText'>"+ this.t +"</p>");
$("#tooltip")
.css("top",(e.pageY - xOffset) + "px")
.css("left",(e.pageX + yOffset) + "px")
.fadeIn("fast");
},

然后是 CSS:

.tooltipText
{
text-transform: uppercase;
/* any style you want */

}

关于php - JQUERY ToolTip - 特定词的样式,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15772762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com