我希望有排名的每顆恆星的反饋,當我在循環的javascript導致
這裏點擊星星是我的代碼現在:
當我點擊第一行顯示該明星的標題。現在,第二行,當我點擊它,它並不表明星的冠軍。
<table class="table table-striped table-hover">
<thead>
<tr>
<th> </th>
<th> </th>
<th>Feedback</th>
</tr>
</thead>
<?php foreach($designation_show->result() as $r){?>
<tr>
<td>
<inut type = "hidden" name = "template_id" id = "template" value=<?php echo $r->t_id;?> />
<?php echo $r->question_description;?>
</td>
<td>
<fieldset id='rate1' class="rating">
<input class="stars" type="radio" id="star5" name="rating" value="5" />
<label class = "full" for="star5" title="Outstanding - 5 stars"></label>
<input class="stars" type="radio" id="star4" name="rating" value="4" />
<label class = "full" for="star4" title="Exceeds Expectation - 4 stars"></label>
<input class="stars" type="radio" id="star3" name="rating" value="3" />
<label class = "full" for="star3" title="Meets Expectation - 3 stars"></label>
<input class="stars" type="radio" id="star2" name="rating" value="2" />
<label class = "full" for="star2" title="Improvement Needed - 2 stars"></label>
<input class="stars" type="radio" id="star1" name="rating" value="1" />
<label class = "full" for="star1" title="Failed - 1 star"></label>
</fieldset>
</td>
<td>
<div id='feedback'></div>
</td>
</tr>
<script>
$(document).ready(function() {
$("#rate1 .stars").click(function() {
var label = $("label[for='" + $(this).attr('id') + "']");
$("#feedback").text(label.attr('title'));
$(this).attr("checked");
});
});
</script>
<?php } ?>
</table>
你的問題是什麼? – Rayon
當我點擊它時,我想在它的標籤下顯示它的標題。 – lothux1987
但是發生了什麼!什麼沒有發生!什麼是您的實際問題 – RiggsFolly