Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/78.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用jquery更改工具提示div的css_Jquery_Html_Css_Tooltipster - Fatal编程技术网

使用jquery更改工具提示div的css

使用jquery更改工具提示div的css,jquery,html,css,tooltipster,Jquery,Html,Css,Tooltipster,在我的网页上,我有许多图标,上面应用了工具提示。 我想要的是,根据图标颜色更改背景颜色。 我无法在主文件中进行更改 有人能告诉我如何更改工具提示div的背景色吗 我已经在下面应用了jquery,但当我从图标中移除光标时,它会改变颜色: $('.icon_box').hover(function(){ // I can check the color of icon here and put below, for testing I have applied orange $('div.too

在我的网页上,我有许多图标,上面应用了工具提示。 我想要的是,根据图标颜色更改背景颜色。 我无法在主文件中进行更改

有人能告诉我如何更改工具提示div的背景色吗


我已经在下面应用了jquery,但当我从图标中移除光标时,它会改变颜色:

$('.icon_box').hover(function(){
// I can check the color of icon here and put below, for testing I have applied orange
  $('div.tooltipster-default').css("background-color", "blue");

});

谢谢。

您需要使用Tooltipster的
功能就绪
选项。比如:

$('.icon_box').tooltipster({
    functionReady: function(origin){
        var originBackgroundColor = origin.css('background-color'),
            tooltip = origin.tooltipster('elementTooltip');

        // I'm not sure if it should be applied on $(tooltip) or one
        // of its children, you'll have to check it out
        $(tooltip).find('.tooltipster-default').css('background-color', originBackgroundColor);
    }
});

“但是当我从图标中移除光标时,它会改变颜色”我不完全确定这意味着什么。到底是什么问题?你能在jsfiddle.net上做一个简单的例子来说明出了什么问题吗?如果你没有CSS选项,你可以添加
!要点
强制样式:
$('div.tooltipster-default').css(“背景色”,“蓝色!要点”)“但当我从图标上移除光标时,它会改变颜色”意味着,鼠标从图标上移出时,我会得到预期的输出(颜色变化)。我想更改悬停在图标上的div的css。但在巴克德的某个地方,它是由tooltipster制作的。我不确定是否在悬停或任何其他操作时调用此函数。我是这个工具提示的新手,如果我有什么问题,很抱歉silly@Vincent我想要这个。不同的背景颜色适合不同的颜色icon@Neha你能添加一把吗?这给了我:TypeError:origin.element工具提示不是我编辑过的函数,请重试。不管怎样,逻辑在这里,请参阅文档以检查详细信息。