My js gets the value of the option option in the select tag. Why is it always the first value? The other choices still get the value of the first one.

clipboard.png

,0,0

clipboard.png

Mar.20,2021

your way of writing must only be the default when you get it. The value of val will change


only if you get the value of val when you are in change.

would you please express your opinion if you step on the answer?

< hr >

the reason must be that you tampered with the unposted code

<!DOCTYPE html>
<html lang="zh">
<head>
    <title>Title</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<select id="sutate" data-options="panelHeight:'auto',editable:false" name="sutate">
    <option value="0">1</option>
    <option value="1">2</option>
</select>
</body>
</html>

run result:

clipboard.png

that's what it's called about select. That's all.

if you really don't know which code affects your code that should be normal, there is a good way to troubleshoot it, which is troublesome, but effective:

is to copy your normal code separately into a new html to see if there is a problem. If there is no problem, add other code from your original page to the new html step by step to know which code has affected it. Yours, however, is most likely to be the following:

1, there are several id=sutate elements
2, there is code dynamically changing the value of select
3, unexpected, for thousands of reasons

Menu