[英]master page link's background colour is changing in Internet explorer but not working in Mozilla Firefox
I have one link whose background colour has to change when I click on it. 我有一个链接,当我点击它时背景颜色必须改变。 So I have used a JavaScript function to do this,but it is working in Internet explorer but not changing in Mozilla Firefox.
所以我使用JavaScript函数来执行此操作,但它在Internet Explorer中工作,但在Mozilla Firefox中没有更改。
The code is below: 代码如下:
function hilite() {
Trend.style.background= "#000000";
}
Here trend is the id of the Link tag. 这里的趋势是Link标签的id。
Link: 链接:
<a id="Trend" style="color: #FFFFFF;
text-decoration: none;" href="ATrendAnalysis.aspx">Trend Analysis</a>
Cs file: Cs文件:
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "ScriptRegistration1", "hilite();", true);
In this case: 在这种情况下:
Trend.style.background= "#000000";
"Trend" is a JavaScript variable, which is not defined. “趋势”是一个JavaScript变量,未定义。 This is NOT referencing an element in the DOM.
这不是引用DOM中的元素。
Use: 采用:
document.getElementById('Trend').style.background= "#000000";
You could also try to apply some styles to the link using CSS by using the pseudo-class selector :active. 您还可以尝试使用CSS通过使用伪类选择器将一些样式应用于链接:active。
:Active would apply the defined style (in your case, it would be change its background color) only while the link is being pressed. :只有在按下链接时,Active才会应用已定义的样式(在您的情况下,它将更改其背景颜色)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.