If I have a <div> that has variable elements in it, each with a different id, which is one number — so for instance, three images with the ids 1, 2 and 3 — how do I write a function to get those ids and then export them all together as an integer instead of a string?
At the moment I have a function that grabs the ids and exports them, but there’s a problem. Say I put three images with ids 1, 2 and 3 into the <div>. When it exports the ids and goes to the database, I don’t get 123’s entry; I get 1, 2, or 3. I imagine it’s because the function is exporting it as 1,2,3 instead of 123. Can anyone help?
My code (where #div is the parent <div> and children are the elements with the ids I want to gather):
$("#submit").click(function () {
$("#div").children().each(function(n, i) {
var boxid = this.id;
// Do something with the ids
});
});
If you want to get the result as 123 integer, you can use
mapmethod and thenjointhe result.http://jsfiddle.net/rEfXb/