<body>
<p style="color:green" id="green" onclick=getIT("green beans")>1.Soy beans </p>
</body>
<script>
function getIT (OneWord){
var theWord= document.getElementById("green");
theWord.innerHTML=OneWord; }
</script>
The above code dosent change. if I type one word only it changes, but if I type a string it dosnt not change. Can't figure out why.
Your html is invalid, you need to rewrite your onclick handler to use
"before and after the function, then wrap your string in single quotes (') - or the other way around:See this demo