<button onclick="myfunctionName('John')">Click</button>
<script type="text/javascript">
function myfunctionName(String){
alert(String);
}
</script>
<!-- Will Show an Alert Box Saying "John" -->
<button onclick="console.log('click')">Click me!!!</button>
<input type="text" id="dt" value="" required oninvalid="setCustomValidity('Please enter e value to process!!')" oninput="setCustomValidity('')" >
<input type='button' value="Save" onclick="processRequest(document.getElementById('dt').value)">
<script>
window.onload=(()=>{document.querySelector("input[id='dt']").value=(new Date()).getFullYear();});
processRequest=((val)=>{
alert(val);
});
</script>
// if you are using onclick attribute you can write like this for example
<button type="button" onclick="myFunction('testParameter')"> Test Button</button>
<script>
function myFunction(myString){
console.log(myString)
}
</script>
<head>
<script>
function x(y)
{
const q = document.getElementById(y);
alert(q.innerHTML);
}
</script>
</head>
<body>
<button id="btn" onclick="x('thing')">Press </button>
<div id="thing"> HELLO WORLD</div>