简体   繁体   English

HTML select 选项在框中打开

[英]HTML select options open in box

I make a selection with HTML select.我用 HTML select 进行选择。 I need the options to be opened in a separate div or popup.我需要在单独的 div 或弹出窗口中打开选项。 I explored resources like jquery and javascript.我探索了 jquery 和 javascript 等资源。 I could not come to a conclusion.我无法得出结论。 Or I called in the wrong way.或者我打错了电话。 I do not know.我不知道。

In other words, not as droptown, but like the options that are clicked.换句话说,不像droptown,而是像被点击的选项。

<select>
 <option></option>
<option>Option 1</option>
<option>Option 2</option>
<option>Option 3</option>
<option>Option 4</option>
<option>Option 5</option>

http://jsfiddle.net/cj0aymh1/ http://jsfiddle.net/cj0aymh1/

The place we clicked for Dropdown should still be clickable.我们点击下拉的地方应该仍然是可点击的。 When I click it, the options should open in a div or a popup.当我单击它时,选项应该在 div 或弹出窗口中打开。

Try this (I used this in many projects)试试这个(我在很多项目中都使用过这个)

 select, ul { height: 100px; overflow: auto; width:300px; border: 1px solid #000; } ul { list-style-type: none; margin: 0; padding: 0; overflow-x: hidden; } li { margin: 0; padding: 0; } label { display: block; color: WindowText; background-color: Window; margin: 0; padding: 0; width: 100%; } label:hover { background-color: Highlight; color: HighlightText; }
 <ul> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST1">TEST1</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST2">TEST2</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST3">TEST3</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST4">TEST4</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST5">TEST5</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST6">TEST6</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST7">TEST7</label></li> <li><label for="regcode"><input type="checkbox" name="regcode" id="regcode" value="TEST8">TEST8</label></li> </ul>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM