javascript - Apply CSS to JQuery tooltip - Stack Overflow

I try to apply a CSS to all the tooltip on my html page but can't find the way to do it. I have do

I try to apply a CSS to all the tooltip on my html page but can't find the way to do it.

I have done my research and found some results here, and there for instance, but can't make it work.

Here is part from my html page:

<div class="col-sm-3 text-center" title="Tooltip title"> </div>

And since I reference all the tooltips on this page:

(function (window, $) {   
    // Set the Tooltips
    $(document).ready(function(){
        $(document).tooltip({
            tooltipClass: "tooltip-styling"
        });
    });
})(window, $);

tooltip-styling is the following CSS class:

.tooltip-styling{
    background-color:red !important;
    color: red !important;
}

Nothing fancy, just wanted to check if the style is applied.

As you have guessed, it is not.

What should i do more?

I try to apply a CSS to all the tooltip on my html page but can't find the way to do it.

I have done my research and found some results here, and there for instance, but can't make it work.

Here is part from my html page:

<div class="col-sm-3 text-center" title="Tooltip title"> </div>

And since I reference all the tooltips on this page:

(function (window, $) {   
    // Set the Tooltips
    $(document).ready(function(){
        $(document).tooltip({
            tooltipClass: "tooltip-styling"
        });
    });
})(window, $);

tooltip-styling is the following CSS class:

.tooltip-styling{
    background-color:red !important;
    color: red !important;
}

Nothing fancy, just wanted to check if the style is applied.

As you have guessed, it is not.

What should i do more?

Share Improve this question edited Jul 20, 2016 at 9:47 Sanjeev Kumar 3,1635 gold badges39 silver badges82 bronze badges asked Jul 20, 2016 at 9:10 MornorMornor 3,8218 gold badges39 silver badges75 bronze badges 2
  • $('.selector').tooltip({ tooltipClass: "tooltip-styling", }); – user4520208 Commented Jul 20, 2016 at 9:13
  • Possible duplicate of Overriding CSS styles of the jQuery UI Tooltip widget – user4520208 Commented Jul 20, 2016 at 9:14
Add a ment  | 

2 Answers 2

Reset to default 2

Fitting your case, the css declaration you have to overwrite is "background" and not "background-color".

https://jsfiddle/nrnLgc36/1/

html

<div class="col-sm-3 text-center" title="Tooltip title">TEST</div>

css

.tooltip-styling{
    background:green !important;
    color: black !important;
}

.col-sm-3 {
  display: block;
  background: #bacd63;
}

javascript

(function (window, $) {

    // Set the Tooltips
    $(document).ready(function(){
        $(document).tooltip({
            tooltipClass: "tooltip-styling"
        });
    });
})(window, $);

Try this:

$( ".selector" ).tooltip( "option", "tooltipClass", "custom-tooltip-styling" );

As explained here: Here

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744967311a4603759.html

相关推荐

  • javascript - Apply CSS to JQuery tooltip - Stack Overflow

    I try to apply a CSS to all the tooltip on my html page but can't find the way to do it. I have do

    1天前
    30

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信