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) undefinedwhich 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(); });更多推荐
发布评论