开发者

Select value on load and change

开发者 https://www.devze.com 2023-03-19 12:21 出处:网络
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:

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');
0

精彩评论

暂无评论...
验证码 换一张
取 消