3 Star 54 Fork 14

Yaohaixiao / dom.js

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
getImages.js 602 Bytes
一键复制 编辑 原始数据 按行查看 历史
import getEl from './getEl'
/**
* 返回这个页面页或者某个DOM元素下的所有图片路径的数组
* ========================================================================
* @method getImages
* @since 1.6.0
* @param {String} el
* @param {Boolean} includeDuplicates
* @return Array
*/
const getImages = (el = 'body', includeDuplicates = false) => {
const $el = getEl(el)
const images = [...$el.getElementsByTagName('img')].map((img) =>
img.getAttribute('src')
)
return includeDuplicates ? images : [...new Set(images)]
}
export default getImages
JavaScript
1
https://gitee.com/yaohaixiao/dom.js.git
git@gitee.com:yaohaixiao/dom.js.git
yaohaixiao
dom.js
dom.js
main

搜索帮助