Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

Set an onclick function with a parameter for an element

<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>
	
 
PREVIOUS NEXT
Tagged: #Set #onclick #function #parameter #element
ADD COMMENT
Topic
Name
3+9 =