Test description: A: Static select item Static select items (can be filled through server-side scripts) can be set directly using $("#drop-down box id").val (selected value). After setting, use $("# drop-down box id" ).val(); can obtain its value correctly.
B: When there is a static that contains a dynamically created option, use $("#selectId").val() Dynamically created (including a static option such as: ), you can pass 1.setTimeout("$("#drop-down box id") .val(" value ")",1) setting. But after using setTimeout, it is incorrect to use $("#drop-down box id").val(); to get the value. Of course, usually your code context The value value is retained. There is no need to retrieve it through .val(). The disadvantage of setTimeout is that it is executed asynchronously. The context when setTimeout is executed is usually not the current function domain.
2. Use try{$(" #Drop-down box id").val();}catch(e){} to block errors, This can run normally in Firefox and IE6.0, but there will be problems with IE6.0's value. C: All are created dynamically In this case, try is used and there is no setting in IE6.0.
In addition, IE6.0 cannot automatically adjust the select width for dynamically created drop-down items, which requires Manual adjustment.
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn