0

i am bubble.io learner and as i use repeating group in bubble.io i can only give id to the element and it will create data table of repeating group.

so my element has same id and multiple occurance. i need to grab the value of those elements and store it in an array using jquery.

any help would be appreciated

thank you

$('#export').click(function() {
  var titles = [];
  var data = [];


  $('#category').each(function() {
    titles.push($(this).text());
  });

  /*
   * Get the actual data, this will contain all the data, in 1 array
   */
  $('#paraname').each(function() {
    data.push($(this).text());
  });
}
Nitin Sawant
  • 7,278
  • 9
  • 52
  • 98
  • id is supposed to be "SINGULAR". If you have multiple elements that are related you should use a data attribute. `` and you can look that up `$('tr[data-id="foo"]')` – epascarello Dec 22 '22 at 17:20
  • having multiple elements with same id is invalid in HTML https://stackoverflow.com/questions/5611963/can-multiple-different-html-elements-have-the-same-id-if-theyre-different-eleme instead try assigning class to your elements – Nitin Sawant Dec 22 '22 at 17:20
  • Side note: Element IDs should be [unique in given page](https://developer.mozilla.org/en-US/docs/Web/API/Element/id): "_If the id value is not the empty string, it must be unique in a document._" You should find a way to make each ID unique. – andrewJames Dec 22 '22 at 17:23
  • i know i can not use same id but i work on bubble.io and i can give id attribute to the element which is in repeating group so all the feild which fall in it will have a div element and same id. i just need to know how can i find all the div with same id and assign a class to it using jquery – user2239404 Dec 23 '22 at 06:52
  • $('[id="category"]').each(function() { $(this).addClass("category"); }); $('[id="paraname"]').each(function() { $(this).addClass("paraname"); }); i am using this code but aint working – user2239404 Dec 23 '22 at 06:53

1 Answers1

0

Please try like this. And I think you should define the variable as let or not var.

$('#export').click(function() {
  let titles = [];
  let data = [];
  $('[id=category]').each(function() {
    titles.push($(this).text());
  });
  /*
   * Get the actual data, this will contain all the data, in 1 array
   */
  $('[id=paraname]').each(function() {
    data.push($(this).text());
  });
})
David F
  • 605
  • 4
  • 10