简体   繁体   English

有没有办法让 div 充当输入字段?

[英]Is there a way to make a div act as an input field?

This is what I currently do.这就是我目前所做的。 This code is on a mobile device, so whenever I select the input field, the keyboard comes up and the current place with a focus loses its focus.这段代码在移动设备上,所以每当我选择输入字段时,键盘就会出现,当前有焦点的位置会失去焦点。

$("#scanner").select();
$("#scanner").on("keyup", function(){
    getScannedItem($(this).val());
    $(this).val('');
    $("#scanner").select();
})

Is there a way to do this in lets say... a div or ap tag?有没有办法做到这一点,比如说……一个 div 或 ap 标签?

You could make an element editable .您可以使元素可编辑

 <div contenteditable="true"> This text can be edited by the user. </div>

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

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