title: How to get data from button attributes?
body: <p>There are several buttons (they creates dynamically) </p>
  
  <pre><code>&lt;button class="common" id="1.1" status="sale" oncontextmenu="rightButton('1.1'); return false" onclick="addOptions('1.1')" number="1"&gt;1&lt;/button&gt;
  </code></pre>
  
  <p>I need to get attributes (class, id, status, number) and insert them into object array. Then input to database.</p>
  
  <pre><code>function saveScheme()
  {
    var table = document.getElementById('schemeTable');
    var elements = table.getElementsByTagName('button');
    var arrayIdButtons = {};
    for(var i = 0; i&lt;elements.length; i++)
    {
      arrayIdButtons[i] = {};
      for(var j = 0; j&lt;4; j++)
      {
        arrayIdButtons[i]["coord"] = elements.item([i]).id; 
        arrayIdButtons[i]["status"] = elements.item([i]).status; 
        arrayIdButtons[i]["type"] = elements.item([i]).class;
        arrayIdButtons[i]["number"] = elements.item([i]).number;
      }
    }
    console.log(arrayIdButtons);
    var data='data=' + JSON.stringify(arrayIdButtons,"", 2);
    $.ajax({
              type: 'POST',
              url: "handler.php",
              data: data,
              cache: false,
              data: data,
              success: function(data) {
                  alert(data)
              }
          });
  }
  </code></pre>
  
  <p>result of this code(<code>console.log(arrayIdButtons);</code>):</p>
  
  <p><a href="https://i.stack.imgur.com/wCreu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wCreu.png" alt="enter image description here"></a></p>