如何在不知道控件名的情况下使用javascript在文本框中的光标位置插入文本 [英] How to insert text at cursor position in textbox using javascript without knowing control name

查看:65
本文介绍了如何在不知道控件名的情况下使用javascript在文本框中的光标位置插入文本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有多个文本框控件。我想在文本框中插入文本,其中指向光标..如何做到这一点?因为有多个文本框控件。

解决方案

使用jQuery,例如:

 <  !DOCTYPE     html  >  

< html xmlns = http://www.w3.org/1999/xhtml >
< head < span class =code-attribute> runat = server >
< title > < / title >
< script src = http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js > < / script >
< script >

(文件)。就绪(函数(){

( 输入:文本。)聚焦(函数(){

I have multiple textbox control. I want to insert text in textbox where cursor is pointed.. how to do this? because there are multiple textbox controls.

解决方案

Use jQuery, e.g.:

<!DOCTYPE html>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script>


(document).ready(function(){


("input:text").focus(function(){


这篇关于如何在不知道控件名的情况下使用javascript在文本框中的光标位置插入文本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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