<!DOCTYPE HTML>
<
html
>
<
head
>
<
title
>
JavaScript
Pass string parameter in onClick function.
</
title
>
</
head
>
<
body
style
=
"text-align:center;"
id
=
"body"
>
<
h1
style
=
"color:green;"
>
GeeksForGeeks
</
h1
>
<
p
id
=
"GFG_UP"
style="font-size: 19px;
font-weight: bold;">
</
p
>
<
p
id
=
"GFG_DOWN"
style="color: green;
font-size: 24px;
font-weight: bold;">
</
p
>
<
script
>
let up = document.getElementById('GFG_UP');
let down = document.getElementById('GFG_DOWN');
let inputEl = document.createElement('input');
inputEl.type = 'button';
inputEl.value = "Click here";
inputEl.addEventListener('click', function () {
GFG_Fun('Parameter');
});
document.body.insertBefore(inputEl, down);
up.innerHTML =
'Click on button to pass the ' +
'string parameter to the function';
function GFG_Fun(parameter) {
down.innerHTML = "String '" +
parameter + "' Received";
}
</
script
>
</
body
>
</
html
>