I am trying to make a script that when you type in a hex value and press submit itchanges the text color to the color inputted.
It seems the problem is the way i am calling the variable "userInput" inside the variable new html
Any Ideas?
<script type="text/javascript">
function changeText3(){
var userInput = document.getElementById('userInput').value;
var oldHTML = document.getElementById('para').innerHTML;
var newHTML = "<span style='color:userInput'>" + oldHTML + "</span>";
document.getElementById('para').innerHTML = newHTML;
}
</script>
<p id='para'>Welcome to the site <b>dude</b> </p>
<input type='text' id='userInput' value='#' />
<input type='button' onclick='changeText3()' value='Change Text'/>