Skip to content

Instantly share code, notes, and snippets.

Created March 14, 2018 17:25
Show Gist options
  • Save anonymous/fcdeea7126ac66fdfc3d5b73d7059e16 to your computer and use it in GitHub Desktop.
Save anonymous/fcdeea7126ac66fdfc3d5b73d7059e16 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
<ul> Ingredients
<li>Sugar</li>
<li>Milk</li>
<li>Eggs</li>
<li>Flour</li>
<li>Baking Soda</li>
</ul>
</body>
</html>
var list = document.querySelectorAll("li");
for ( var i = 0; i < list.length; i++){
list[i].addEventListener( "click", function(e){
alert("Has cliqueado en " + e.target.innerText);
}
)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment