I'm trying to change on of my linkbutton's text color to red when a user clicks on the link. 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.
<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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.