Home › Forums › JavaScript › Learning JS › Reply To: Learning JS
September 22, 2014 at 1:40 pm
#184155
Participant
First and most importantly, how does the JS know to run when a button is clicked, there is no trigger in the HTML.
This line stores the target in the variable comments
var comments = document.getElementById('comments');
Then later,
comments.addEventListener('click',replybox_onClick);
Event listener is attached to listen to any clicks, then it just runs the replybox_onClick
function.
Hope that helps,
-Alen