为什么 Opera 浏览器中的 HTML 选择框不起作用?

发布于 2024-08-06 18:51:40 字数 1078 浏览 2 评论 0原文

我的页面上有一个简单的选择元素:

<select id="info_routes" size="10"></select>

这个选择框在文档准备好时通过 jquery 在页面加载时填充:

for (var route in _routes) {
  var val   = _routes[route].id;
  var key   = 'route_'+val;
  $("<option />").attr({id: key, value: val}).appendTo('#info_routes');
  $('#info_routes > #'+key).text(_routes_text(_routes[route]));
}

结果是:

<select id="info_routes" size="10">
  <option id="route_1" value="1">9 - Two Nations Crossing</option>
  <option id="route_2" value="2">13S - Prospect</option>
  <option id="route_3" value="3">13N - Brookside Mall</option>
  ...
</select>

问题是当这个元素在 Opera 10 中渲染时会发生这种情况:

请参阅此处附加的照片 http://tinypic.com/r/n4yrk9/4 (注意,我使用了tinypic.com,请原谅我选择的第一个免费图像托管网站上的大量广告,我在谷歌上找到了它)

它的行为就好像苹果命令/电脑控制按钮被按住:(

这是不应该的是一个多选元素,但在选择另一个项目后,这些项目仍然被选中。而且,选择第一个项目时根本不会突出显示

任何关于为什么会发生这种情况以及如何补救的想法!

I have a simple select element on my page:

<select id="info_routes" size="10"></select>

This select box gets populated at page load via jquery at document ready:

for (var route in _routes) {
  var val   = _routes[route].id;
  var key   = 'route_'+val;
  $("<option />").attr({id: key, value: val}).appendTo('#info_routes');
  $('#info_routes > #'+key).text(_routes_text(_routes[route]));
}

The result is:

<select id="info_routes" size="10">
  <option id="route_1" value="1">9 - Two Nations Crossing</option>
  <option id="route_2" value="2">13S - Prospect</option>
  <option id="route_3" value="3">13N - Brookside Mall</option>
  ...
</select>

The problem is when this element is rendered in Opera 10 this happens:

See attached photo here http://tinypic.com/r/n4yrk9/4
(Note, I used tinypic.com, please excuse the abundance of ads I picked the first free image hosting site I found on google)

It behaves as if the apple-command/pc-ctrl button is being held :(

This is not supposed to be a multi-select element, yet the items remain selected after another item is selected. Also the first item when selected doesn't highlight at all.

Any ideas as to why this is happening and how to remedy it would be much appreciated!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

我也只是我 2024-08-13 18:51:40

我无法使用 Opera10(XP,无小部件)重现您的问题 - 您发布的结果代码提供了一个选择下拉列表。

尝试将您的代码粘贴到 w3schools - tryit 窗口 并查看它是否

加载了任何精美的小部件?

祝你好运麦克D

I can't reproduce your problem using Opera10 (XP, no widgets) - the result code you posted gives a single select dropdown.

Try to paste your code into w3schools - tryit window and see what it does there

any fancy widgets loaded?

good luck MikeD

始终不够 2024-08-13 18:51:40

http://www.w3schools.com/TAGS/att_select_multiple.asp

尝试禁用此功能这样一次只能选择一个选项。

有关选项选择的更多信息:
http://www.w3schools.com/TAGS/att_option_selected.asp
http://www.w3schools.com/TAGS/tag_option.asp

除此之外,我会看看其他原因造成的。

http://www.w3schools.com/TAGS/att_select_multiple.asp

Try disabling this so that only one option can be selected at a time.

More info on option selects:
http://www.w3schools.com/TAGS/att_option_selected.asp
http://www.w3schools.com/TAGS/tag_option.asp

Other than that, I would look at something else causing it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文