I have a radio group, with a function that shows the value when I check the selection. It works well. I added a default option with checked="yes". that also applied well. By logic I assumed that the text of the option selected by default should also appear. After all, it is selected in the same way. I want that to happen. I leave a file where the example is
The html:
<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>
This is the function:
$(function() {
var $radBtn = $("#odontologia");
$radBtn.click(function() {
var $radChecked = $radBtn.find(':radio:checked');
$("#forro").text('')
.append($radChecked.val());
});
});
Thanks for your cooperation.