<script type="text/javascript">
function changeText(newText) {
	elem = document.getElementById("para1");
	elem.value = newText;
}
</script>
</head>

<body>
<input id="para1" value='Some text here'>

<button onclick="changeText('newtext');">blue</button>
<button onclick="changeText('othertext');">red</button>
</body>
</html>
Published in: JavaScript
Download

Related snippets