[英]How to change color of linkbutton when clicked(visited link)?
I'm trying to change on of my linkbutton's text color to red when a user clicks on the link. 当用户单击链接时,我试图将我的linkbutton的文本颜色更改为红色。 Therefore, as a user I can identify that I've already clicked on this link.
因此,作为用户,我可以确定我已经单击了此链接。
<body>
<form id="form1" runat="server">
<div>
<asp:GridView ID="FileGrid" runat="server" AutoGenerateColumns="False" OnRowCommand="FileGrid_RowCommand">
<Columns>
<asp:BoundField DataField="OriginalFileName" HeaderText="OriginalFileName" SortExpression="OriginalFileName" />
<asp:BoundField DataField="AttachmentGUID" HeaderText="AttachmentGUID" SortExpression="AttachmentGUID" />
<asp:TemplateField>
<ItemTemplate>
<asp:LinkButton ID="Generate_PDF" runat="server" Text="Generate PDF" CommandName="GeneratePDF_Click" CommandArgument="<%#Container.DataItemIndex %>" />
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
</div>
</form>
This is what I've tried using javascript. 这就是我尝试使用javascript进行的尝试。
<script>
document.getElementById('Generate_PDF').onclick = function () {
this.style.backgroundColor = '#ff0000';
};
</script>
Use this: 用这个:
document.getElementById('Generate_PDF').onclick = function () {
this.style.color= '#ff0000';
};
Because you need to change the color of text, not the background. 因为您需要更改文本的颜色,而不是背景。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.