I have 3 radio buttons and a parragraph. What I have to do is to check a button, and then, change the color of the paragraph.
<p id="pColor">Este párrafo cambiará de color según el valor del radio seleccionado.</p>
<form name="formColor">
<input type="radio" name="color" value="red" id="red"/>Rojo
<input type="radio" name="color" value="green" id="green"/>Verde
<input type="radio" name="color" value="blue" id="blue"/>Azul
</form>
This is my jQuery code:
$(document).ready(function(){
$("input[name='color']").change(function(){
cambiaColor()
});
});
var cambiaColor=function(){
$("input").each(function(){
$("#pColor").css("color",$(this).val());
});
}
The text always turn blue, no matter what button I checked