title: I'm getting undefined when i'm getting the button id in Safari
body: <p>I have this code working fine in Chrome, Firefox on pc and android devices but it does not work in macbook with safari or Iphone with sarafi or Chrome. I'm getting undefined at the variable grupo. So I'm sending &quot;undefined&quot; in the Ajax request.</p>
  <p><strong>Context:</strong> I have a group of buttons created on document.ready with an id. And I have a function to know the id of the clicked button, and send that ID with an Ajax post request and I'm getting undefined as response.</p>
  <p>This code work well in every web navigator. Just for context.</p>
  <pre class="lang-js prettyprint-override"><code>$(document).ready(function(){
    //testing Jquery
    //console.log(&quot;esta funcionando Jquery&quot;);
  
    var basicProfile = new URLSearchParams(window.location.search);
      const email = basicProfile.get(&quot;e&quot;);
      const imagen = basicProfile.get(&quot;imageURL&quot;);
      var idFechaAgenda;
  
      generarGrupos();
  
  function generarGrupos() {
      $.ajax({
        url: 'php-grupos.php',
        type: 'POST',
        data: {email},
        success: function(response) {
          grupos = JSON.parse(response);
          document.getElementById('profilePicture').src = imagen;
          document.getElementById('lblNombre').innerText = grupos[0].nombreDocente;
          document.getElementById('lblCorreo').innerText = email;
          let template = '';
          var cont = 0;
          grupos.forEach(response =&gt; {
            template += ` // This work fine in every web navigator
                    &lt;tr taskId=&quot;${grupos[cont].idDocente}&quot;&gt;
                      &lt;td style=&quot;display:none&quot;&gt;${grupos[cont].idDocente}&lt;/td&gt;
                      &lt;td class=&quot;text-center align-middle fw-bold&quot;&gt;${grupos[cont].grupoDocente}&lt;/td&gt;
                      &lt;td id=&quot;resultado${grupos[cont].idDocente}&quot;&gt;
                        &lt;button type=&quot;button&quot; id=&quot;${grupos[cont].grupoDocente}&quot; class=&quot;btn-verAlumnos btn-primary bg-dark w-100 fw-bold&quot;&gt;Ver alumnos&lt;/button&gt;
                      &lt;/td&gt;
                    &lt;/tr&gt;
                  `       
                  cont++;
          });
          $('#tableFechas').html(template);
        },
        error: function(xhr, status, error){
          console.log(xhr);
          console.log(status);
          console.log(error);
        }
      });
    }
  </code></pre>
  <p>With this code, I'm getting var grupo = undefined with <code>console.log</code> only in MacOS using Safari or Iphone using Safari and Chrome. With another devices works fine.</p>
  <pre><code>$(document).on('click', '.btn-verAlumnos', (e) =&gt;{
      const element = $(this)[0].activeElement;
      var grupo = $(element).attr('id'); // i think this is the problem :(
      $.ajax({
        url: 'php-listaAlumnos.php',
        data: {grupo},
        type: 'POST',
        success: function(response){
          let alumnos = JSON.parse(response);
          let table = '';
          var cont = 0;
          alumnos.forEach(alumno =&gt; {
            table += `
              &lt;tr AlumnoId=&quot;${alumnos[cont].num}&quot;&gt;
                &lt;td class=&quot;text-center align-middle fw-bold&quot;&gt;${alumnos[cont].num}&lt;/td&gt;
                &lt;td id=&quot;Alumno${alumnos[cont].num}&quot; class=&quot;text-center align-middle fw-bold&quot;&gt;${alumnos[cont].matricula}&lt;/td&gt;
                &lt;td class=&quot;text-center align-middle fw-bold&quot;&gt;${alumnos[cont].nombre}&lt;/td&gt;
              &lt;/tr&gt;
            `
            cont++;
          });
          $('#tableAlumnos').html(table);
          $('#alumnosModal').modal('show');
        },
        error: function(xhr, status, error){
          console.log(xhr);
          console.log(status);
          console.log(error);
        }
      });
    });
  </code></pre>
  <p>Question: There is another way to get the id of the clicked button and sent it with the post request without getting undefined at group variable? (I think this is the problem).</p>