Tengo un grupo radio con una funcionfunción para mostarmostrar el texto del Valor. Puse para qque por defecto tenga una opcionopción seleccionada. Quiero qque el texto de esa opcionopción aparezca tambientambién por defecto sin, sin embargo no oudepude. Pense q podria
Pensé que podría ese mismo texto estar escrito, aparte del texto del inputinput
, y qque cambie al seleccionarse por el de la opción seleccionada.
<span class="ef-example-1-rating" id="odontologia">
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-5" name="ef-example-1-rating-input-1" value="Hello5" >
<label for="ef-example-1-rating-input-1-5" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-4" name="ef-example-1-rating-input-1" value="Hello4">
<label for="ef-example-1-rating-input-1-4" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-3" name="ef-example-1-rating-input-1" value="Hello3">
<label for="ef-example-1-rating-input-1-3" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-2" name="ef-example-1-rating-input-1" value="Hello2">
<label for="ef-example-1-rating-input-1-2" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-1" name="ef-example-1-rating-input-1" value="Hello1" checked="yes">
<label for="ef-example-1-rating-input-1-1" class="ef-example-1-rating-star"></label>
<br />
<p id="forro" style="color:red;"></p>
</span>
EstaEste es la funcionel código:
$(function() {
var $radBtn = $("#odontologia");
$radBtn.click(function() {
var $radChecked = $radBtn.find(':radio:checked');
$("#forro").text('')
.append($radChecked.val());
});
});
Gracias
$(function() {
var $radBtn = $("#odontologia");
$radBtn.click(function() {
var $radChecked = $radBtn.find(':radio:checked');
$("#forro").text('')
.append($radChecked.val());
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<span class="ef-example-1-rating" id="odontologia">
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-5" name="ef-example-1-rating-input-1" value="Hello5" >
<label for="ef-example-1-rating-input-1-5" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-4" name="ef-example-1-rating-input-1" value="Hello4">
<label for="ef-example-1-rating-input-1-4" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-3" name="ef-example-1-rating-input-1" value="Hello3">
<label for="ef-example-1-rating-input-1-3" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-2" name="ef-example-1-rating-input-1" value="Hello2">
<label for="ef-example-1-rating-input-1-2" class="ef-example-1-rating-star"></label>
<input type="radio" class="ef-example-1-rating-input" id="ef-example-1-rating-input-1-1" name="ef-example-1-rating-input-1" value="Hello1" checked="yes">
<label for="ef-example-1-rating-input-1-1" class="ef-example-1-rating-star"></label>
<br />
<p id="forro" style="color:red;"></p>
</span>