JQUERY工具提示-样式化特定的单词


JQUERY ToolTip - Styling Specific Words

我有这个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>

我想有一个或两个单词在工具提示粗体和所有小写…如何在不影响工具提示重置的情况下做到这一点?

而不是显示为:

这是工具提示

I'd like:

this is THE TOOLTIP

有什么想法吗??

你可以给你要添加的文本添加一个特定的类,然后通过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  */
}