我有div
tt
ID,我在JavaScript中编写代码,在运行时代码中添加title
属性(tooltip
),其中包含:
$("#tt")
.css("left", (mouse.x - 240) + "px")
.css("top", (mouse.y - 258) + "px")
.attr("title", title)
.tooltip('show');
现在我想在title
属性设置颜色。请建议我如何使它工作。
答案 0 :(得分:0)
如果我理解正确,你想改变原生标题的颜色......
这是一种CSS3方式
http://jsfiddle.net/dimshik/tDQWN/8662/
来源:https://css-tricks.com/css-content/
body {
padding: 10px;
}
a {
color: #900;
text-decoration: none;
}
a:hover {
color: red;
position: relative;
}
a[title]:hover:after {
content: attr(title);
padding: 4px 8px;
color: red;
position: absolute;
left: 0;
top: 100%;
white-space: nowrap;
z-index: 20px;
-moz-border-radius: 5px;
-webkit-border-radius: 5px;
border-radius: 5px;
-moz-box-shadow: 0px 0px 4px #222;
-webkit-box-shadow: 0px 0px 4px #222;
box-shadow: 0px 0px 4px #222;
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -webkit-gradient(linear,left top,left bottom,color-stop(0, #eeeeee),color-stop(1, #cccccc));
background-image: -webkit-linear-gradient(top, #eeeeee, #cccccc);
background-image: -moz-linear-gradient(top, #eeeeee, #cccccc);
background-image: -ms-linear-gradient(top, #eeeeee, #cccccc);
background-image: -o-linear-gradient(top, #eeeeee, #cccccc);
}
<p>Here is some text and a <a href="#" title="Hello, i am a link">LINK</a>
with a red title on it. </p>
<p> And here is another one <a href="#" title="This is another link">Link</a> eleifend leo.</p>
答案 1 :(得分:0)
你目前正在使用这个:
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>
/* Change Blocked with the title you are loo*/
<script>$(document).ready(function(){
$("div[title*='Blocked']").css("background-color", "yellow");});
</script>
/* Everything with the text Blocked in the title will change color*/
<div title="Blocked ality">One</div>
<div title="Blocked">Two</div>
我希望它有所帮助。 V / R 塞尔吉奥