Last active
June 28, 2017 13:37
-
-
Save jmlavoier/36560836a0e19240c0b97d6424a08c9e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const allP = document.getElementsByTagName('p'); | |
// Criando a função de callback | |
// Todos os eventos recebem como parâmetro o objeto event | |
// que permite pegarmos o elemento clicado event.target, | |
// e realizar outras funcionalidades. | |
const goToLastPosition = function (event) { | |
event.target.parentNode.appendChild(event.target); | |
} | |
// Percorro todos os elementos e aplico a função ao evento. | |
for (let i = 0; i <= allP.length; i++) { | |
allP[i].addEventListener('click', goToLastPosition); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment