jQuery - 获取 div 中的所有图像 src 并放入字段

jQuery - get all src of images in div and put into field(jQuery - 获取 div 中的所有图像 src 并放入字段)
本文介绍了jQuery - 获取 div 中的所有图像 src 并放入字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将 本教程 修改为我的要求,但我有一个问题.我是 jQuery 的初学者,我想从特定的 div 中获取所有图像源并将它们放入字段中.有一个变量images,它是字段并包含一些图像,但我想从 div 中获取所有图像源并将它们放入字段 images 中.我知道这并不复杂,但我真的不知道该怎么做.

I want to modified this tutorial to my requirements but there is one problem to me. I'm a beginner with jQuery and I would like to get all image sources from specifïc div and put them into field. There is a variable images which is field and contain some images but I want instead of this get all image sources from div and put them into field images. I know that isn't such a complicated but I don't really know how to do it.

来源在这里http://jsfiddle.net/s5V3V/36/

这是来自 jsfiddle 源代码的变量 image,我想从 div 中填充,而不是我现在拥有的:

This is the variable image from source on jsfiddle which I want fill from div instead what I have there now:

images = ['http://kimjoyfox.com/blog/wp-content/uploads/drwho8.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho7.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho6.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho5.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho4.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho3.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/dr-whos-tardis.png',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho9.jpg',
    'http://kimjoyfox.com/blog/wp-content/uploads/drwho1.jpg'];

提前感谢.

推荐答案

In dom ready try

In dom ready try

var images = $('.thumbnailArrows').children('img').map(function(){
    return $(this).attr('src')
}).get()

这篇关于jQuery - 获取 div 中的所有图像 src 并放入字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!

本站部分内容来源互联网,如果有图片或者内容侵犯您的权益请联系我们删除!

相关文档推荐

how to remove this error quot;Response must contain an array at quot; . quot;.quot; while making dropdown(如何删除此错误quot;响应必须在quot;处包含数组。创建下拉菜单时(Q;))
Why is it necessary to use `document.createElementNS` when adding `svg` tags to an HTML document via JS?(为什么在通过JS为一个HTML文档添加`svg`标签时,需要使用`Document.createElementNS`?)
wkhtmltopdf print-media-type uses @media print ONLY and ignores the rest(Wkhtmltopdf print-media-type仅使用@media print,而忽略其余内容)
How to trim() white spaces from a string?(如何从字符串中去掉()空格?)
price depend on selection of radio input(价格取决于无线电输入的选择)
calculate price depend on selection without button(根据没有按钮的选择计算价格)