I've a combo box and want to select an option value. I'm using something like:
$("#comState_city option:eq(0)").attr("value",chk[i]);
$("#comSt开发者_C百科ate_city option:eq(0)").attr("selected","selected");
But this isn't firing value change event. I want the onchange handler be called when I changed the value of a select element.
$('#comState_city option:eq(0)').trigger('change');
Try this one:
$("#comState_city").change(function(){
alert($(this[this.selectedIndex]).val());
});
精彩评论