js_设置光标到文本的最后位置

div_right_table_tr1_td3_input2.focus(function(){
if(input1.setSelectionRange){//火狐
input1.setSelectionRange(input1.value.length, input1.value.length); //将光标定位在textarea的开头,需要定位到其他位置的请自行修改
input1.focus();
}else if(input1.createTextRange){//ie
var rtextRange =input1.createTextRange();
rtextRange.moveStart(‘character‘,input1.value.length);
rtextRange.collapse(true);
rtextRange.select();
}
});

时间: 2024-08-07 09:25:17

js_设置光标到文本的最后位置的相关文章

javascript获取以及设置光标位置

一. 获取光标位置: // 获取光标位置 function getCursortPosition (textDom) { var cursorPos = 0; if (document.selection) { // IE Support textDom.focus (); var selectRange = document.selection.createRange(); selectRange.moveStart ('character', -textDom.value.length);

PHP----练习----光标离开文本框时变色

题目::创建若干个输入文本框,当光标离开文本框的时候如果文本框为空,则将文本框背景色设置为红色,如果不为空则为白色. 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 2 <html xmlns="http://www.w3.org/1999/

05使用CSS设置字体和文本样式

使用CSS设置字体和文本样式: 1.定义字体类型font-family 用法: font-family:name; font-family:ncursive|fantasy|monospace|serif|sans-serif name表示字体名称,可指定多种字体,用空格隔开.按优先顺序排列.如果字体名称包含空格,则应该使用括号()括起来. font是一个复合属性,所谓复合属性是指该属性能够设置多种字体属性,用法如下: font:font-style||font-variant||font-we

141设置屏幕中文本的横向对齐方式(扩展知识:设置标签行间距)

效果如下: ViewController.h 1 #import <UIKit/UIKit.h> 2 3 @interface ViewController : UIViewController 4 @end ViewController.m 1 #import "ViewController.h" 2 #import "KMLabel.h" 3 4 @interface ViewController () 5 - (void)layoutUI; 6 @

List的设置值,跟变量的位置关系(变量范围的变化导致结果差别很大)

我们想要的结果是: [RegnTypeCharge: null,null,null,null,1,null,null,null,null,null,null,null,null,null,null,][RegnTypeCharge: null,null,null,null,hehe,null,null,null,null,null,null,null,null,null,null,]com.[email protected]addbf1com.[email protected]42e816 需要

动态设置ImageView的宽高以及位置

如何动态设置ImageView的宽高以及位置 package com.pic; import android.app.Activity; import android.os.Bundle; import android.util.Log; import android.view.ViewGroup.LayoutParams; import android.widget.ImageView; public class PicTest extends Activity { private final

javascript获取textarea中所选文本的开始位置、结束位置和选择的文本

javascript获取textarea中所选文本的开始位置.结束位置和选择的文本. demo: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>javascript获取textarea中所选文本的开始位置.结束位置和选择的文本</title

[DevExpress]设置饼状图的Lable位置

关键代码: /// <summary> /// 设置饼状图的Lable位置 /// </summary> /// <param name="series">Series</param> /// <param name="lablePosition">PieSeriesLabelPosition枚举</param> public static void SetLablePosition(this

(转)TextView 设置背景和文本颜色的问题

在做一个项目,突然遇到如下问题 比如:在color.xml中定义了几个颜色 <color name="white">#FFFFFF</color> <color name="orange">#DF8326</color> 复制代码 又给TextView 设置了字体颜色和背景色 <TextView android:id="@+id/hello" android:textColor="@