jquery中的show()方法不起作用(show() method in jquery not working)

编程入门 行业动态 更新时间:2024-10-27 14:34:26
jquery中的show()方法不起作用(show() method in jquery not working)

我有以下代码。

$(document).ready(function() { var factoryImage = document.getElementById("photo"); factoryImage.src = document.getElementById('<%= FactoryImageFileNameHF.ClientID %>').value; factoryImage.show(); });

我有jquery的以下脚本源。

<script src="/Scripts/jquery-3.0.0.min.js" type="text/javascript"></script>

我收到以下错误。

jQuery.Deferred exception: factoryImage.show is not a function TypeError: factoryImage.show is not a function at HTMLDocument.<anonymous> (http://localhost:3373/Intranet/OHS/InteractiveMap/FactoryLayoutSettings.aspx:403:38) at j (http://localhost:3373/Scripts/jquery-3.0.0.min.js:2:29588) at k (http://localhost:3373/Scripts/jquery-3.0.0.min.js:2:29902) undefined

哪个就行了factoryImage.show();

这是图像

<img id="photo" src="/Icons/Factory Layout.png" style="display:none"/>

我可以确认jquery中的factoryImage不为null或未定义。 有一些我想念的东西,我知道这很容易,但我无法弄清楚。 为什么show方法不起作用?

I have the following code.

$(document).ready(function() { var factoryImage = document.getElementById("photo"); factoryImage.src = document.getElementById('<%= FactoryImageFileNameHF.ClientID %>').value; factoryImage.show(); });

I have the following script source for jquery.

<script src="/Scripts/jquery-3.0.0.min.js" type="text/javascript"></script>

I get the following error.

jQuery.Deferred exception: factoryImage.show is not a function TypeError: factoryImage.show is not a function at HTMLDocument.<anonymous> (http://localhost:3373/Intranet/OHS/InteractiveMap/FactoryLayoutSettings.aspx:403:38) at j (http://localhost:3373/Scripts/jquery-3.0.0.min.js:2:29588) at k (http://localhost:3373/Scripts/jquery-3.0.0.min.js:2:29902) undefined

which is right on the line factoryImage.show();

Here is the image

<img id="photo" src="/Icons/Factory Layout.png" style="display:none"/>

and I can confirm that factoryImage in the jquery is not null or undefined. There is something I am missing which I know will be easy but I can't figure it out. Why is the show method not working?

最满意答案

问题是factoryImage不是jQuery元素而是DOM元素,这应该可行

$(document).ready(function () { var factoryImage = $("#photo"); factoryImage.attr("src", document.getElementById('<%= FactoryImageFileNameHF.ClientID %>').value); factoryImage.show(); });

The problem is that factoryImage is not a jQuery element but a DOM element, this should work

$(document).ready(function () { var factoryImage = $("#photo"); factoryImage.attr("src", document.getElementById('<%= FactoryImageFileNameHF.ClientID %>').value); factoryImage.show(); });

更多推荐

本文发布于:2023-08-05 00:01:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1423191.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:不起作用   方法   show   jquery   method

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!