Javascript Events (Part 2)

Why we are using text as paramter in the function change_paragraph_text() ??

Here the parameter mentioned inside the function change_paragraph_text() is actually a variable name, and since we have called the function above in the input statement with the parameter (this.value), so whatever we input will be given as a parameter to this function where it is declared and then whatever is stored using that variable (text) is used to change the default text, which is mentioned in the very next line of the function declaration. The default text changes its value according to the input given in real-time because of the event onkeyup.

To make it easier, suppose “Hello” is to be given as input, then when it is typed, it goes to (this.value) and the function is called, then “Hello” gets stored in the variable text, which is then used to modify the paragraph with the mentioned id.

Hope this helps!

1 Like

@sanjaynh22 In request you to post queries related to web development training on in future.