Refreshing Form Elements

var mySelect = $("#mySelect"); mySelect [0].selectedIndex = 1; mySelect.selectmenu("refresh"); $("#myCheckbox").prop("checked",true).checkboxradio("refresh"); $("#myRadio").prop("checked",true).checkboxradio("refresh"); $("#mySlider").val(100).slider("refresh");

When programmatically changing items in a form, such as adding options to a select, you need to call the refresh function on the item. Following are some examples of adjusting form elements using jQuery and then refreshing them.

Get jQuery and JavaScript Phrasebook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.