Home > database >  How to get all the elements with the same id in jquery
How to get all the elements with the same id in jquery

Time:12-23

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());
  });
}

CodePudding user response:

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());
  });
})
  • Related