javascript - Safari dynamically assigning values ​​to select does not take effect
大家讲道理
大家讲道理 2017-06-12 09:27:42
0
2
883

I need to dynamically obtain the value of the option selected by the user from the background and then dynamically assign the value to the select when the user enters this page again

This method can take effect in chrome, but it cannot take effect in safari. I hope you can help me.

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(2)
大家讲道理

When operating the attributes of option, please use prop to operate the attributes instead of attr

给我你的怀抱

This is a bug in Safari, solution:

<select multiple>
    <optgroup disabled hidden></optgroup>
    <option value="0">All</option>
    <option value="1">Test 1</option>
    <option value="2">Test 2</option>
    <option value="3">Test 3</option>
    <option value="4">Test 4</option>
</select>

Add an optgroup tag in front of all option tags, and give the attributes disabled and hidden

So easy!

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template