开发者

Javascript Combo Box Select from div with onclick for iPhone

开发者 https://www.devze.com 2023-03-03 22:08 出处:网络
how can i get into the combo box without clicking on the Combo Box. Just by clicking on a link, div or something else? onclick=\"....\"

how can i get into the combo box without clicking on the Combo Box. Just by clicking on a link, div or something else? onclick="...."

The ComboBox (multiple) has style="visibility: hidden". It should run on an iphone.

Sample开发者_JAVA技巧 Code:

<div onclick="jumpintoComboBox()">click</div><select id="direct" multiple style="visibility: hidden">...</select>

function jumpintocombobox() { $('#direct').focus() }

Thanks.


The select element is one of the few form controls that requires a native click event to activate focus in Safari on iOS. Not even using document.createEvent and document.dispatchEvent will work. It's part of the browser's security model to only allow deliberate 'taps' from the user to open the form control.

One way to achieve what you want would be to position the select element for your combo box in the area you want the user to click and style it differently, perhaps so it appears like a button if that's what you want.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号