我需要在通过 ajax 加载一些内容时选择选项。这是代码..
<select id="select" name="select" onchange="onClick(this.options[this.selectedIndex].value)">
<option value="1" >Yes</option>
<option value="0">No</option>
function onClick(value) {
var p = document.getElementById('select');
if(p.value != value) {
$('select>option:eq(1)').prop('selected',true)); /*this portion doesn't work */
}
setTimeout("onClick(1)",5000); /* value 1 for display yes which will display by ajax load file add.php but i can't select yes which already set by ajx url and load content */
}
$.ajax({
url:'add.php',
type:'GET',
data : {id : value},
success : function(response){
$('div#content').html(response);
}
});
}});}