admin管理员组文章数量:1320670
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');
});
本文标签: javascriptGet ID of all divs with a class on a pagejqueryStack Overflow
版权声明:本文标题:javascript - Get ID of all divs with a class on a page - jquery - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742063291a2418685.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论