Solution 1 :

Changing my lt()/gt() range fixed it. I also added some debug code to see the html of every element I was pushing to the array (the outerHTML portion):

$('#bAcep').on('click', function() {
  var text = $(this).parent().parent().parent().find('td:gt(0):lt(6)'); //<-- Changed to 6 instead of 7
  text.each(function() {
    array.push($(this).text());
    console.log("outerHTML: "+$(this).get(0).outerHTML); //<-- Added
  });
$.each(array, function(index, val) {
  console.log("Array Index: " + index + ", Array Val: "+val);
 })
})

It gave me the correct indices I needed:

Dev Console Screenshot

Problem :

I am trying to push the text of td elements into an array for later use. I am using a click event on a button that is in the last column of a tr element (I marked out an IP Address).

screenshot

I am attempting to grab every element that is greater than 0, and less than 7, however, my dev console is showing that the last one is still grabbed, which would be the button.

This is the console output:

    Array Val: xx.xxx.xx.xxx
    Array Val: AT&T
    Array Val: some random text
  3 Array Val: <--- Notice the 3 here? That should the next 3 elements, which is fine
    Array Val: <--- THIS SHOULD NOT BE HERE SINCE IT WASN'T SUPPOSED TO GET PUSHED TO THE ARRAY

Here is my code to create this array:

//Click the button
$('#bAcep').on('click', function() {
    //Get the parent of the parent of the parent of the button, find the 'td' elements
    //between the first and the last (1 - 6).
    var text = $(this).parent().parent().parent().find('td:gt(0):lt(7)');
    //Now add each of those to the array
    text.each(function() {
        array.push($(this).text());
    });
    //Loop through array and print to console
    $.each(array, function(index, val) {
        console.log("Array Val: "+val);
    })
})

By