我已經通過類似的問題進行了搜索,但沒有找到適合自己的東西。Uncaught TypeError:無法爲ImageButton設置null的屬性'src'
我想在特定條件(t> 80)下更改ImageButton的ImageURL,但是我得到的是未捕獲的TypeError:無法設置null的屬性'src'。我<head>
代碼:
$(document).ready(function() {
//doing other stuffs
setInterval(function() {
$(".industrial.tank.size.one").each(function() {
$(this).industrial(t);
if (t > 80) {
// document.getElementById('btnV11').ImageURL = "~/Images/Valve/Valve-gray-left.png";
document.getElementById('btnV11').src = "../../Images/Valve/Valve-gray-left.png";
});
}, 3000);
});
和<body>
:
<asp:ImageButton ID="btnV11" runat="server" Height="51px" ImageUrl="~/Images/Valve/Valve-alarm-left.gif" Width="53px" OnClientClick="ShowControlPanel_P11(); return false;"/>
爲什麼我得到這個錯誤?
如果ImageButton的被放置在內容頁,然後ID不會被DOM – anomepani