【问题标题】:How do you change the background color of an html table entry background when something specific happens?当发生特定事情时,如何更改 html 表格条目背景的背景颜色?
【发布时间】:2014-08-13 18:51:36
【问题描述】:

我正在制作一个 html 表格,我需要某些框的背景来改变 selenium webdriver 运行后的颜色。例如,如果 webdriver 在站点中运行时没有错误,它将将该应用程序的表中的框更改为绿色,或者如果出现错误,则将框颜色更改为红色。我知道我需要为此使用 java 脚本,但我以前从未使用过它。

【问题讨论】:

  • 这里不适合简单地索取代码。请发布您迄今为止尝试过的任何代码。

标签: javascript html css selenium webdriver


【解决方案1】:

您可以使用 JavaScript 属性 document.body.style.background

这是一个例子:

function changeBackground(color) {
    document.body.style.background = color;
}

点击这里了解更多信息:How do I change the background color with JavaScript?

例如,要在用户按下回车键时更改框的背景颜色,请单击:Changing background color of text box input not working when empty

确实,您需要适应自己的元素。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多