Reputation: 79
I want to change the css of one td through jquery. Please help on this. This is not working for me $("#tdTopMenu").css({ "backgroundColor": "black", "color": "white" });
aspx code:
<table border="0" cellspacing="0" width="100%">
<tr>
<td id = "tdTopMenu" runat = "server" style="width: 100%" class="hideColumn">
<asp:Literal ID="Literal1" runat="server"></asp:Literal>
</td>
</tr>
</table>
Jquery code:
<script type="text/javascript">
$(document).ready(function () {
$("#jMenu").jMenu({
ulWidth: '150',
effects: {
effectSpeedOpen: 300,
effectTypeClose: 'slide'
},
animatedText: false
});
$("#tdTopMenu").css({ "backgroundColor": "black", "color": "white" });
});
</script>
Upvotes: 0
Views: 295
Reputation: 25628
$("#<%=tdTopMenu.ClientID%>").css({ "backgroundColor": "black", "color": "white" });
ASP.NET Web Form changes the IDs when they are rendered to HTML so you need to retrieve the client-side id, rather than using the server ID.
Alternatively you can add ClientIdMode="Static" to tdTopMenu.
Upvotes: 1
Reputation: 4737
Try this:
$("#"<%=tdTopMenu.ClientID%>).css("backgroundColor","black").css("color","white");
Upvotes: 1
Reputation: 9446
id != tdTopMenu
delete runat = "server" on element <td>
and re try
Upvotes: 1