我想问一下,当我从虚拟键盘输入到<div>时,是否有人知道从虚拟键盘直接将数据实时发送到<input>字段的方法。
我尝试过不同的方法,但似乎都不管用。关于stackoverflow的类似问题给了我一些想法,但keyup函数或getElementById在我的情况下不工作,请帮助。
下面是我的代码。
<!DOCTYPE html>
<head>
<link rel="stylesheet" href="softkeys-0.0.1.css">
<style>
body { background-color:#fafafa; font-family:'Roboto';}
</style>
</head>
<body>
<input type="text" id="a" name="code" class="form-control input-lg">
</form>
<div style="border:2px inset #AAA ;height:50px; width:500px;" id="d" >
</div>
<script>
$('.softkeys').click(function() {
$('#d').text($(this).val());
});
</script>
<div class="softkeys" data-target="input[name='code']">
</div>
</div>
</div>
</div>
<script src="http://code.jquery.com/jquery-1.12.4.min.js"></script>
<script src="softkeys-0.0.1.js"></script>
<script>
$(document).ready(function(){
$('.softkeys').softkeys({
target : $('.softkeys').data('target'),
layout : [
[
['`','~'],
['1','!'],
['2','@'],
['3','#'],
['4','$'],
['5','%'],
['6','^'],
['7','&'],
['8','*'],
['9','('],
['0',')'],
['-', '_'],
['=','+'],
'delete'
],
[
'q','w','e','r','t','y','u','i','o','p',
['[','{'],
[']','}']
],
[
'capslock',
'a','s','d','f','g','h','j','k','l',
[';',':'],
["'",'"'],
['\\','|']
],
[
'shift',
'z','x','c','v','b','n','m',
[',','<'],
['.','>'],
['/','?'],
['@']
]
]
});
});
</script>
</body>
</html>一切正常,但问题是,当我尝试从虚拟键盘向<div>或从<input>向<div>发送数据时,脚本不起作用。
$('.softkeys').click(function() {
$('#d').text($(this).val());
});https://stackoverflow.com/questions/47700013
复制相似问题