I need to get the ID of every div with a class and send it across to another PHP file. I would assume I need all of the ID's in one variable. The ID's will be put into a mysql query where I will find data that does not equal these ID's. How can this be done?
I have tried jQuery's each function but you cannot put all of the data from that function into one variable. At least not the way i did it.
This is what i've tried.
$('.newsItem').each(function(){
alert (this.id);
});
Thanks in advance.
I need to get the ID of every div with a class and send it across to another PHP file. I would assume I need all of the ID's in one variable. The ID's will be put into a mysql query where I will find data that does not equal these ID's. How can this be done?
I have tried jQuery's each function but you cannot put all of the data from that function into one variable. At least not the way i did it.
This is what i've tried.
$('.newsItem').each(function(){
alert (this.id);
});
Thanks in advance.
Share Improve this question edited May 23, 2013 at 6:11 Robin Maben 23.1k16 gold badges68 silver badges99 bronze badges asked Sep 4, 2012 at 17:45 Jacob WindsorJacob Windsor 6,9906 gold badges35 silver badges49 bronze badges 1- I'm unable to think of a good reason why you'd want to do this. Can't you just use an ordinary HTML form? – Blazemonger Commented Sep 4, 2012 at 17:47
2 Answers
Reset to default 13var ids = $('.className').map(function(){
return this.id;
}).get();
DEMO
Put the data in a array
Var ids= new Array();
$('.newsItem').each(function(){
ids[] = $(this).attr('id');
});