Here's a TextBox:
<asp:TextBox ID="UsernameTextBox" runat="server" class="BlockInput"></asp:TextBox>
I wanna give an asp textbox
some color but its not changing color
<script type="text/javascript">
function BlockInput() {
var elements = document.getElementsByClassName("BlockInput");
for (var i = 0; i < elements.length; i++) {
elements[i].readOnly = true; // works
elements[i].style.color = "#000000";// does not work!
}
}
window.onload = BlockInput;
</script>
When I view source I could see the style being added:
<input name="ctl00$MainContent$UsernameTextBox"
type="text" id="MainContent_UsernameTextBox"
class="BlockInput" readonly="" style="color: rgb(0, 0, 0);">
I also made sure nothing is overwriting the css.