這裏有一個文本框:無法更改文本框的顏色?
<asp:TextBox ID="UsernameTextBox" runat="server" class="BlockInput"></asp:TextBox>
我想給一個asp textbox
一些色彩,但它不變色
<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>
當我查看添加源我能看到的樣式:
<input name="ctl00$MainContent$UsernameTextBox"
type="text" id="MainContent_UsernameTextBox"
class="BlockInput" readonly="" style="color: rgb(0, 0, 0);">
我也確定沒有什麼東西會覆蓋CSS。
你的意思是臉色還是背景色? – melancia
只是對最佳做法的評論:http://stackoverflow.com/questions/559150/best-practice-for-using-window-onload –
是的傢伙其背景即時通訊設法改變 – meda