views:

16

answers:

2

Hey Guys,

I am wokring 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?

+1  A: 
var srcs = new Array();

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

var result = srcs.join(',');
David Morton
@David - Don't forget `srcs.push($(this).attr('src'))` as an option...reads a bit clearer, at least in my opinion.
Nick Craver
Fantastic, I appreciate it its dead on. for the looping and variable building. There's a side problem though. $('.grid_pic:has(border)').each(function(){alert(1);}); doesn't shout. My images look like this. <img src='http...' border=3 class=grid_pic> If I remove the has:border/has:border=3, it shouts.
A: 

This is a concise approach to getting it:

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