开发者

JQuery: Get SRC for each image that has specific atrtibute

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜