javascript - 如何通过jquery从html中获取图像标签

标签 javascript jquery

所以我有一个数据集,它在变量entry.content中返回类似这样的内容:

<p style="float:right;margin:0 0 10px 15px;width:240px"> <img src="http://citysportsblog.com/wp-content/uploads/2011/09/RagnarNE.jpg" width="240"> </p><p>Have you heard of the epic adventure that is the</p>

我如何通过 jquery 从中获取 img src url?

最佳答案

<删除> 假设您只有一张图像: var sourceUrl = $('img').attr('src');

var sourceUrl = $(entry.content).find('img').attr('src');

关于javascript - 如何通过jquery从html中获取图像标签,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7518290/

相关文章:

javascript - AngularJS:删除 Aria 属性

javascript - JQuery:检查元素是否在正常流程中

javascript - 使用对 Canvas 的外部引用渲染 SVG

javascript - x-editable,当字符串为空时如何显示特定值?

javascript - 使用 Vue、Cypress 和 Cucumber 进行测试时如何使用类?

javascript - 获取客户的一些身份信息

javascript - 为什么我的dispatchEvent适用于鼠标事件但不适用于按键事件

javascript - 如何将选择的值回显到文本框

javascript - 使用javascript将具有多个图像的html div转换为单个图像

jquery - VueJS 选择 dom 中的特定元素