lundi 28 août 2017

Can't get all data-type

function displayType() {
  const li = document.querySelector('li');
  const liType = li.getAttribute('data-type');
  alert(liType);
}
<ul>
  <li onclick="displayType()" data-type="Anime">Naruto</li>
  <li onclick="displayType()" data-type="Movie">Inception</li>
  <li onclick="displayType()" data-type="TV-Series">Game of Thrones</li>
</ul>

When i click, only alert 'Anime' . How can i see all of them?




Aucun commentaire:

Enregistrer un commentaire