on_btn_gen_click is called (because the
onclick attribute of the button has been set so).
Inside the function, the method
document.getElementById(id) is used to select the elements from the HTML document. To mention about the content,
.value is used in the case of input element and
.innerHTML in the case of paragraph element (that's how the input and output works).
document.getElementById("inCount").value means the value of the input element and
document.getElementById("pSeries").innerHTML means the content of the [output] paragraph element.
Note that the function
parseInt() is used with the input value in order to convert it from string to integer
Fibonacci series generation takes place inside the for loop, where each new elements is appended to the buffer string output. Finally, the string is assigned to the output paragraph element, and now the user gets the output.
And finally, see it in action: