我想学习如何使用 JavaScript(或 jQuery 库)来访问一个 url,该 url 表示为 optgroup 标记内的 option 标记的值。
使用包含选项标签的简单的一级选择标签,解决方案可以类似于本文中描述的解决方案:
<FORM NAME="nav"><DIV>
<SELECT NAME="SelectURL" onChange=
"document.location.href=
document.nav.SelectURL.options[document.nav.SelectURL.selectedIndex].value">
<OPTION VALUE="http://www.cs.tut.fi/~jkorpela/forms/jsnav.html"
SELECTED>Please select an item:
<OPTION VALUE="http://www.cs.tut.fi/~jkorpela/forms/">
Main page on HTML forms
<OPTION VALUE="http://www.cs.tut.fi/~jkorpela/forms/choices.html">
Choices in HTML forms
<OPTION VALUE="http://www.cs.tut.fi/~jkorpela/forms/tables.html">
Tables and forms
<OPTION VALUE="http://www.cs.tut.fi/~jkorpela/forms/methods.html">
Form submission methods (GET and POST)
</SELECT><DIV>
</FORM>
我尝试将它与 optgroup 标签内带有选项标签的两级选择标签一起使用——它对我不起作用。我会感谢您在调整此代码方面的帮助。