<a id="ya" class="link" href="https://yandex.ru" target="_blanck" translate="no" lang="ru" tabindex="1" style="display:block; text-decoration: none;" data-my="Проверка связи">Yandex</a>

<br>
<button onclick="getAttr()">Get attributes</button>
<button onclick="magic()">Magic </button>
<button onclick="toggleStyle()">On/Off style</button>
<div id="out"></div>
a { color: black; font-size: 1.6rem; }
a:first-letter {
  color: red;
}
function getAttr() {
  var ya = document.getElementById("ya");
  var out = document.getElementById("out");
  var str = "";
  //console.table(ya.attributes);//))))

  out.innerHTML = "";
  str += "<table><tr><th>Name</th><th>Value</th></tr>";
  for (var i = 0, len = ya.attributes.length; i < len; ++i) {
    str += "<tr><td>" + ya.attributes[i].name + "</td><td>" + ya.attributes[i].value + "</td></tr>";
  }
  str += "</table>";

  out.innerHTML += str;
}

/* Добавить удалим изменим атрибуты*/
function magic() {
  var ya = document.getElementById("ya");

  for (var i = 0, len = ya.attributes.length; i < len; ++i) {
    if (ya.hasAttribute("lang")) ya.setAttribute("lang", "de");
    if (ya.hasAttribute("tabindex")) ya.removeAttribute("tabindex");
    if (ya.hasAttribute("translate")) ya.removeAttribute("translate");
    if (ya.hasAttribute("target")) ya.removeAttribute("target");
    if (!ya.hasAttribute("data-super")) ya.setAttribute("data-super", "The Best of the best");
  }
  
  console.log("Work ", ya.getAttribute("id"));
}

/* Маленький переключатель стиля */
function toggleStyle() {
  var ya = document.getElementById("ya");
  if(ya.hasAttribute("style"))
    ya.removeAttribute("style");
  else
    ya.setAttribute("style","display:block; text-decoration: none;");
}

External CSS

This Pen doesn't use any external CSS resources.

External JavaScript

This Pen doesn't use any external JavaScript resources.