Skip to content

Instantly share code, notes, and snippets.

@themonster2015
Forked from anonymous/fiddle.html
Created March 14, 2018 17:26
Show Gist options
  • Save themonster2015/50c25bfa43509b96e852f9053ef62caf to your computer and use it in GitHub Desktop.
Save themonster2015/50c25bfa43509b96e852f9053ef62caf 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