简体   繁体   English

如何从自定义占位符触发 select 更改事件

[英]How to trigger select change event from custom placeholder

I have custom placeholder above select control.我在 select 控件上方有自定义占位符。 but the click event is not triggering when I click the custom placeholder, please suggest the best way to achive the select event, with out using jquery.但是当我单击自定义占位符时单击事件未触发,请建议在不使用 jquery 的情况下实现 select 事件的最佳方法。

在此处输入图像描述

Please check the code请检查代码

 <div id='placeholder' style='font-size:10px; dispaly:none;background-color:red;position:absolute;left:10px'> Options </div> <select id='selectcontrol' style='background-color:yellow; height:40px'> <option>Option A</option> <option>Option B</option> <option>Option C</option> </select>

  • You can wrap your select and placeholder div with another div.您可以用另一个 div 包装您的selectplaceholder div div。
  • Make select 's background transparent使select的背景透明
  • Make sure that your placeholder div is below the select using position:absolute for both of the elements确保您的placeholder div低于select使用position:absolute对于这两个元素

 <div style="background-color:yellow;height:40px;width:100px"> <div id='placeholder' style='font-size:10px;background-color:red;position:absolute;left:10px'> Options </div> <select id='selectcontrol' style='background-color:transparent; height:inherit;width:inherit;position:absolute;'> <option>Option A</option> <option>Option B</option> <option>Option C</option> </select> </div>

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

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