如果我点击标签,我想打开选择按钮,
这是代码
<label>sachin</label>
<select>
<option>1</option>
<option>2</option>
<option>3</option>
<option>4</option>
</select>
在 css 或 jquery 中有什么办法吗?我不确定这件事。
fiddle :http://jsfiddle.net/Yh3Jf/
最佳答案
这里不需要 javascript,只需使用 CSS 设置样式并使用指针事件即可:
<label>
<select>
<option value="0">Zero</option>
<option value="1">One</option>
</select>
</label>
相对的CSS是
label:after {
content:'\25BC';
display:inline-block;
color:#000;
background-color:#fff;
margin-left:-17px; /* remove the damn :after space */
pointer-events:none; /* let the click pass trough */
}
这是一个丑陋的 fiddle 示例:https://jsfiddle.net/1rofzz89/
关于jquery - 一旦我点击标签选择按钮应该打开,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15249958/