【发布时间】:2021-07-19 07:00:40
【问题描述】:
- 我想使用 span 标签 元素更改 img src 值
- 我已经获得了 span 标签的价值,但我找不到改变的方法 img src 值
- 问题是嵌入在img src中的span标签
- 完成所需的 src 链接 span id 值
-
我使用波纹管函数获取跨度标记值
$('#icon').text(data.icon);
它将输出为
03n
所以我想将 img src 更新为
<img src="http://openweathermap.org/img/w/**span_value_shoud_be_there**.png"/>
我尝试了几种这样的方法
<img src="http://openweathermap.org/img/w/<span id='icon'></span>.png"
但我无法得到解决方案。 欣赏你的回答 谢谢
【问题讨论】:
-
您的问题不清楚。请更详细地解释问题所在,并附上minimal reproducible example
-
图片src在页面加载openweathermap.org/img/w/.png上是不是完全一样?如果是这样:href=$('img').attr('src').replace('.png',txt+'.png');$('img').attr('src',href); txt 是您已经从图标中获得的 var...
-
@sinisake 你能解释一下吗
标签: javascript html jquery image