【发布时间】:2016-07-09 10:53:09
【问题描述】:
我搜索了类似的问题,但没有找到适合我的东西。
我想在特定条件下 (t>80) 更改 ImageButton 的 ImageURL,但我得到的是 未捕获的 TypeError:无法设置属性 'src' of null。我的<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 放置在内容页面中,则 DOM 找不到 id
标签: javascript jquery imagebutton imageurl