$(".treatment-btn").click(function()
{
$("#treatmentModal").modal('show');
$('.treatment-form')[0].reset();
$('#treatmentModal #treatment_time option').removeAttr("selected");
$('#treatmentModal #treatment_time option[value=""]').attr("selected", "selected");
}); //when i click on this button it resets form successfully but select option is not reset.
function makeEditHtml(response) {
var price = response[0].treatment_price.split(".")[0];
var cent = response[0].treatment_price.split(".")[1];
$("#treatmentModal #treatment").val(response[0].treatment_name);
$("#treatmentModal #price").val(price);
$('#treatmentModal #cent option[value='+cent+']').attr("selected", "selected");
$('#treatmentModal #treatment_time option').removeAttr("selected");
$('#treatmentModal #treatment_time option[value='+response[0].treatment_duration+']').attr("selected", "selected"); //i select it again at here after ajax call
$.each(response, function(i)
{
$("#treatmentModal input[type=checkbox][value="+response[i].worker_id+"]").prop("checked",true);
});
$("#treatmentModal").modal('show');
}
//當ajax請求觸發時,我會調用這個函數,我以相同的形式追加數據,但選擇框的值沒有被選中。它顯示正確的螢火蟲,但不顯示在屏幕上。第一次工作正常選擇選項2次jquery不能正常工作
錯誤請您創建一個工作小提琴或片段複製的問題? –
不,我不能讓它有大代碼 –
他的意思是[創建一個jsfiddle](https://jsfiddle.net/)。你不能擁有更多代碼的原因是因爲你沒有描述你的問題,而只是發佈了一段代碼。 – JiFus