[英]src of dynamicly generated image is undefined
I have an HTML block I create dynamically. 我有一个动态创建的HTML块。 I cannot get the
src
property of an image inside this block. 我无法在此块中获取图像的
src
属性。
The following are the properties from the Chrome developer console: 以下是Chrome开发者控制台中的属性:
typeof(image)
"object"
image.html()
"<img src="../images/icons/quickshare/enabled/accounting/abacus_48.png">"
image.src
undefined
image.attr("src")
undefined
image.prop("src")
undefined
As you can see, the HTML of the image
object has the correct content, but I cannot access the src
property. 如您所见,
image
对象的HTML具有正确的内容,但是我无法访问src
属性。 What could be the cause? 可能是什么原因?
If that's the HTML ( html()
returns innerHTML
), you currently have the parent element of the image 如果那是HTML(
html()
返回innerHTML
),则当前拥有图像的父元素
try 尝试
image.find('img').prop('src')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.