不是用javascript去模拟select,而是从某个标签就可以控制到select。不知道有没有人知道该怎么操作。
<a href="###">弹出下拉框</a>
<select>
<option>1</option>
<option>2</option>
<option>3</option>
</select>
问题不是模拟select,而是用页面中的某个标签去控制select。就好像下面这段代码:
<label for="userName">用户名:</label>
<input type="text" name="user_name" id="userName" />
点击这个label的时候焦点会出现在input里面。
现在我把这个input换成select,当然点击过去也只是焦点在select上,但是并不能把它展开。
模拟select的话,我也不用跑到这里问了。我不知道js是不是能做到,还是我描述的还是有问题。
天蓬老师2017-04-10 14:24:29
请直接在SegmentFault
中搜索下拉框
,已经有很多很详细的答案了。
http://segmentfault.com/q/1010000000438884
http://segmentfault.com/q/1010000000144556
怪我咯2017-04-10 14:24:29
你是说的这种效果吧?
http://line25.com/wp-content/uploads/2012/css-menu/demo/index.html
css:http://line25.com/wp-content/uploads/2012/css-menu/demo/style.css
大家讲道理2017-04-10 14:24:29
可以使用 ul+li 标签进行模拟。当然也有许多插件。
下拉框:http://demo.tutorialzine.com/2011/02/converting-jquery-code-plugin/
多选下拉框:http://www.erichynds.com/examples/jquery-ui-multiselect-widget/demos/
阿神2017-04-10 14:24:29
人家说的不是这些模拟的菜单项或者其他,他说的是点击select框右边的下拉按钮时会调用什么事件,或者说什么事件可以触发select的下拉操作。
目前我也正在寻求这个事件,未果~~继续。遇到蛋疼的需求