正文onclick转到文本区域 [英] Body onclick go to textarea

查看:93
本文介绍了正文onclick转到文本区域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这看起来似乎不是有用的脚本,但是我需要一些可以使用户在页面上的任意位置单击并且光标将转到文本区域的东西.

This may not seem like a useful script, but I need something that will basically allow the user to click anywhere on the page and the cursor will go to the textarea.

我如何想象这种情况是通过拥有,但我对javascript做到这一点并不了解.

How I imagine this happening is by having but I don't know that much about javascript to do this.

当用户单击正文,段落,图像或正文中的任何内容时,光标将自动进入文本区域,并且他可以键入文本区域.

When the user clicks on the body, paragraph, image, or anything inside the body the cusor will automatically go to the textarea and he will be able to type in it.

我知道这似乎对任何事情都不有用,但是请相信我,我对此很有用.感谢您的帮助!

I know this doesn't seem like it would be useful for anything, but trust me, I have a use for it. Thanks for the help!!

推荐答案

易于使用jquery.但是,我不知道它有多有用.

Easy with jquery. But how useful, I don't know.

$('body').on('click', function(){
  $('textarea').focus();
});

这篇关于正文onclick转到文本区域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆