[英]Showing a textarea with a shortcut but without inserting the shortcut key
$(document).keydown(function(event) {
if(event.keyCode === 70) {
$.("#myTextarea").css('display','block');
$.('textarea').focus();
}
The thing is when i click f and the div is visible in the textarea there is letter f in it 问题是当我单击f并且div在文本区域中可见时,其中有字母f
$(document).keydown(function(event) {
if(event.keyCode === 70) {
$.("#myTextarea").css('display','block');
$.('textarea').focus();
return false;
}
Basically you need to prevent the default event behavior by return false from the function or calling event.preventDefault(). 基本上,您需要通过从函数返回false或调用event.preventDefault()来防止默认事件行为。
http://api.jquery.com/event.preventDefault/ http://api.jquery.com/event.preventDefault/
try this: 尝试这个:
$(document).keydown(function(event) {
if(event.keyCode === 70) {
$.("#myTextarea").val(" ");
$.("#myTextarea").css('display','block');
$.('textarea').focus();
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.