0
我有一个单选按钮一个字段里面是这样的:设置字段集单选按钮值
<fieldset class="rating" id="ratingSystem">
<input type="radio" id="star5" name="rating" value="5" autocomplete="off" /><label class="full" for="star5" title="Awesome - 5 stars"></label>
<input type="radio" id="star4" name="rating" value="4" autocomplete="off" /><label class="full" for="star4" title="Pretty good - 4 stars"></label>
<input type="radio" id="star3" name="rating" value="3" autocomplete="off" /><label class="full" for="star3" title="Meh - 3 stars"></label>
<input type="radio" id="star2" name="rating" value="2" autocomplete="off" /><label class="full" for="star2" title="Kinda bad - 2 stars"></label>
<input type="radio" id="star1" name="rating" value="1" autocomplete="off" /><label class="full" for="star1" title="Sucks big time - 1 star"></label>
</fieldset>
而且我想要是设置它的默认值一个jQuery后在DONE完成后,像下面的函数:
textarea的值设置得很好,但是我无法在数据对象返回的值来设置字段集单选按钮的值。
data.Rating是数值,可以包含1-5的值;
这是不工作的一部分:
$('input[name=rating]:checked').val(data.Rating).attr('checked', true);
如何设置的单选按钮值到在data.Rating返回一个?