我已经在HTML div字段中添加了Javascript文本元素,现在我希望文本颜色为白色。我还想对文本进行其他一些更改。现在我想知道如何设置文本元素的样式或是否可以 以这种形式是可能的。
(翻译成Google翻译,可能包含错误)
这是我的JavaScript代码:
var bghtooltipin = document.getElementById('bgh-tooltipin1');
var bghtooltipout = document.getElementById('bgh-tooltipout1');
bghtooltipin.addEventListener('mouseover', bghtooltipinmouseOver);
bghtooltipin.addEventListener('mouseout', bghtooltipoutmouseOut);
function bghtooltipinmouseOver() {
bghtooltipout.innerHTML = 'Go to Login';
}
function bghtooltipoutmouseOut() {
bghtooltipout.innerHTML = ' ';
}
there are 2 ways, either use css classes or direct
style
manipulationIt looks like you want to change the text color when the user mouses over the button. CSS has a pseudo-class class that covers this usecase. Take a look at https://developer.mozilla.org/en-US/docs/Web/CSS/:hover