未捕获的类型错误:无法为 ImageButton 设置属性 'src' 的 null
Uncaught TypeError: Cannot set property 'src' of null for ImageButton
我已经搜索了类似的问题,但我没有找到适合我的东西。
我想在特定条件 (t>80) 下更改图像按钮的图像URL,但我得到的是未捕获的类型错误:无法将属性"src"设置为 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;"/>
为什么我会收到此错误?
id 将
不同于您在服务器端代码中设置的 id。 将btnV11
替换为<%= btnV11.ClientID %>
$(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.ClientID %>').src = "../../Images/Valve/Valve-gray-left.png";
});
}, 3000);
});
相关文章:
- Javascript使用变量设置属性
- 如何在自动完成时设置属性标题
- 未捕获的类型错误:无法设置属性'innerHTML'如果为null,则将脚本移动到正文不会;不起作用
- 未捕获的类型错误:无法设置属性'背景'的未定义
- 无法设置属性'innerHTML'在javascript中为null
- Haxe Javascript:在不使用Reflect的情况下按名称获取和设置属性
- Jquery为每个元素设置属性
- 从骨干集合筛选模型,然后为这些模型设置属性
- 我们可以设置属性'id'到不同的'按钮'通过使用javascript或jquery的循环
- 如何在javascript对象中设置属性的类型,就像mongoose模式设计一样
- emscripten+sdl=引发异常:TypeError:无法设置属性'widthNative'的未定
- 未捕获的类型错误:无法设置属性'onclick'为null.已尝试window.onload
- Backbone JS Promises在模型上设置属性之前解析
- Highcharts无法设置属性'的值;要点':对象为null或未定义
- 无法设置属性'round'的未定义
- 通过 Javascript 设置 C# 属性值
- 在 app.locals 上设置属性和调用 app.set() 有什么区别?
- 不引人注目地设置属性后函数失败
- j查询在设置属性后在后续单击时不读取数据属性
- IE错误:无法设置属性'的值;样式':对象为null或未定义