I have a select that appears on certain value (500) I need to be able to let it load on 500 and after it loads just change it to 50. I already managed to do this doing:
$select = $('select[name="content-table-redesign_length"]');
$select.val('50');
however, even th开发者_运维技巧ough the select value changes it doesn't reload the table as it would normally if the user were the one to change the value of the select. How can I make it emulate that change. Basically, how can I get it to do automatically what it does normally when a user changes the value.
$select.val('50').change();
This will trigger the change javascript.
then applies the change to the select element :
$(select).change();
you can use jQuery trigger to trigger the onChange event
$select.trigger('change');
精彩评论