jquery dynamic setting selected does not take effect

jquery dynamic setting selected does not take effect

Pit of old projects

Prop must be used, but attr attribute cannot be used otherwise it cannot succeed. For such elements as checkbox, radio and select, the selected attribute corresponds to "checked" and "selected", which are also inherent attributes, so you need to use the prop method to operate to get the correct result.
insert image description here

Guess you like

Origin blog.csdn.net/weixin_37064409/article/details/129529009