嘿ii有选择框与长方法绑定到它的html中的选择框看起来像这样:
HTML:
<select id="select1">
<option>First select Advertiser</option>
<?php
buildSelectOptionsFromPagination(); // Dynamically build the options list
?>
</select>
Javascript:
$('#select1').change(function(){
alert('#select1');
$('#innerP').remove();
$('#innerH').remove();
$('#waitmsg').append(' ...</h2></p>');
$("#show_c ").attr("disabled", true);
$.ajax({
url: 'observer.php',
data: "ctrl=in&v_id="+v_id,
success: function(data) {
var newData = "<option id=\"firstopt_insert\"> blah blah <\/option>" + data;
$('#in111').html(data);
$('#in222').trigger('change');
},
error: function (request, status, error) {
alert(request.responseText+"\nThere was an server error please refresh the page 1 ");
}
});
});
现在我尝试从外部触发此选择框更改方法但没有成功,我触发了 2 方法,1. 按索引选择选项,效果很好:
$('#select1 option')[5].selected = true;
2 现在我想像这样触发更改方法方法但没有成功:
$('#select1').trigger('change');
or
$('#select1').bind('change', function(){ ; });
它只是不触发任何事情,为什么?