Hey i started learning JS today and i thought of trying to make a drop down color changer , i have tried many things but i cant seem to get it to work, i also tried onchange instead of onclick but still nothing , any help appreciated
HTML:
<label for="color">Choose a color: </label>
<select id="text" name="colorpicker">
<option value="red" onclick="red()">Red</option>
<option value="green" onclick="green()">Green</option>
<option value="blue" onclick="blue()">Blue</option>
<option value="purple" onclick="purple()">Purple</option>
</select>
<p id="text">This text changes color</p>
JAVASCRIPT:
function red() {
console.log((document.getElementById("text").style.color = "red"));
}
function green() {
console.log((document.getElementById("text").style.color = "green"));
}
function blue() {
console.log((document.getElementById("text").style.color = "blue"));
}
function purple() {
console.log((document.getElementById("text").style.color = "purple"));
}