Tôi đang cố gắng tự động chọn tùy chọn được chọn bằng jquery sau khi tìm nạp giá trị tùy chọn cần được chọn. Tuy nhiên, nó không hoạt động trong Chrome. Nó hoạt động trong firefox và IE 9. Tại sao nó lại như vậy? chức năng điền là một điền vào các giá trị. (res chức năng, chỉ reset các giá trị lấp đầy bởi chức năng điền và không phải là quan trọng đối với câu hỏi này)tùy chọn jquery chọn không hoạt động trong chrome
function fill(thisValue) {
$('#inputString').val(thisValue);
$.post("get.php?op=category", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$("#mymenu option[value='"+data+"']").attr('selected', 'selected');
$('#mymenu').attr("disabled","disabled");
}
});
$.post("get.php?op=name", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#nameString').val(data);
$('#nameString').attr("disabled","disabled");
}
});
$.post("get.php?op=author", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#authorString').val(data);
$('#authorString').attr("disabled","disabled");
}
});
$.post("get.php?op=publisher", {queryString: ""+thisValue+""}, function(data){
if(data.length >0) {
$('#publisherString').val(data);
$('#publisherString').attr("disabled","disabled");
}
});
setTimeout("$('#suggestions').hide();", 200);
}
function res(inputString) {
$('#publisherString').attr("disabled", false);
$('#publisherString').val('');
$('#nameString').attr("disabled",false);
$('#nameString').val('');
$('#authorString').attr("disabled",false);
$('#authorString').val('');
$('#mymenu').attr("disabled",false);
$('#mymenu option').attr('selected', false);
}
Cố gắng thay đổi 'attr ('đã chọn', 'đã chọn')' thành 'prop ('đã chọn', đúng)' –