如何在更改后禁用每个选择框?
HTML:
<select class="URating" step="1">
<option value="volvo">Volvo</option>
<option value="saab">Saab</option>
</select>
<div id="result_1"></div>
<select class="URating" step="2">
<option value="Lancer">Lancer</option>
<option value="BMW">BMW</option>
</select>
<div id="result_2"></div>
jQuery的:
<script type="text/javascript">
$(document).ready(function(){
$(".URating").change(function(){
var steps = $(this).attr("step");
$.post('rating/module.php', {RatingID:$(this).val(), News:"15", Step:steps},
function(data){
$("#result_"+steps).html(data);
//DISABLE THIS SELECT BOX HERE
});
});
});
</script>
答案 0 :(得分:1)
这应该有效:
$(document).ready(function(){
$(".URating").change(function(){
var steps = $(this).attr("step");
$.post('rating/module.php', {RatingID:$(this).val(), News:"15", Step:steps},
function(data){
$("#result_"+steps).html(data);
$('select[step=' + steps + ']').prop('disabled', 'disabled');
});
});
});
答案 1 :(得分:1)
<script type="text/javascript">
$(document).ready(function(){
$(".URating").change(function(){
var $select = $(this);
var steps = $select .attr("step");
$.post('rating/module.php', {RatingID:$(this).val(), News:"15", Step:steps},
function(data){
$("#result_"+steps).html(data);
//DISABLE THIS SELECT BOX HERE
$select.attr('disabled','disabled');
});
});
});
</script>
答案 2 :(得分:1)