开发者

JQuery: Get SRC for each image that has specific atrtibute

开发者 https://www.devze.com 2022-12-22 15:38 出处:网络
I am wok开发者_开发技巧ring on a dialog, where in execution I want to round up all items that have a specific attribute and place an attribute value of their\'s into a comma delited list.

I am wok开发者_开发技巧ring on a dialog, where in execution I want to round up all items that have a specific attribute and place an attribute value of their's into a comma delited list.

This is as far as I have gotten, which isnt far.

buttons: {       

'Hook': function(){ $('.grid_pic:has(border=3)').(loop through id's, grab src, build variable with srcs comma delimeited)

}

Any ideas?


var srcs = new Array();

$('.grid_pic[border=3]').each(function() { 
    srcs[srcs.length] = $(this).attr('src');
});

var result = srcs.join(',');


This is a concise approach to getting it:

var commalist = $('.grid_pic:has(border=3)').map(function() { 
                  return $(this).attr('src');
                }).get().join(',');
0

精彩评论

暂无评论...
验证码 换一张
取 消