<input class="textBox" type="text" id="aaaa" name="aaaa"
size="25" maxlength="64"/>在输入用户名时,想要将原来在text中的所有文本设置为选中,用JS怎么实现,求教
size="25" maxlength="64"/>在输入用户名时,想要将原来在text中的所有文本设置为选中,用JS怎么实现,求教
解决方案 »
- 在框架内,我用一些JS特效,结果点击出现上一次页面的残留
- 请帮忙分析一段js代码,非常感谢,能说点就说一点,希望大家不吝赐教
- 有关form传递参数的问题
- 怎样使两个页面交换数据?
- 请问这段JS代码是如何加密的?该如何解密呢? 在线等
- 请问,如何用超链来提交一个form,为何我以下Javascript代码无法提交正确form,谢谢!
- window.close
- <input> 分为 text、radio、等。。可不可以用text[i]或者radio[i]等调用控件
- 请教一个窗口问题——————我先谢谢了!!
- 如何能将Access数据库文件自动在控制面版OBDC建立好系统DSN连接??
- 编码问题:表单post提交,含有中文,为什么传到后台是乱码捏?
- js特效
<input id="TBselect" name=TBsou size=25 onMouseOver="this.focus()" onBlur="if (this.value =='') this.value='请填入姓名'" onFocus="this.select()" onClick="if (this.value=='请填入姓名') this.value=''"type="text" value="请填入姓名"/>
size="25" maxlength="64" onfocus= "this.select() "/>
var Textbox1 = document.getElementById(“text”);
Textbox1.focus();
Textbox1.select();
}
<script>
document.getElementById("dd").select();
</script>
像这样就可以解决你的问题了。
<script language="javascript" src="src=" http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<script language="javascript">
$(function(){
//此代码的意思是获取第一个文本,如果你要获取的文本不是第一个,那么依次往上加就可以了
$(":text:eq(0)").select();})
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>无标题文档</title>
<script type="text/javascript">
function lo(){
document.getElementById("aaa").select();
}
</script>
</head><body onload="lo()">
<input type="text" id="aaa" value="test" />
</body>
</html>复制查看即可
<head>
<script type="text/javascript">
window.onload = function(){
var oInput = document.getElementsByTagName("input")[0];
oInput.focus();
oInput.select();
}
</script>
</head>
<body>
<input type="text" name="username" value="check"/>
</body>
</html>
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="Email.WebForm1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title></title> <script src="jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(document).ready(function() {
$("#TextBox1").focus();
}); </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</form>
</body>
</html>
我这是用jquery实现的,记住先下载jquery-1.4.2.min.js文件,jquery官网有
<script src="jquery/jquery-1.4.2.min.js" type="text/javascript"></script>
这是引用地址
var today;
today = new Date();
var yy = today.getYear();
if(yy<1900) yy = yy+1900;
var MM = today.getMonth()+1;
if(MM<10) MM = '0' + MM;
var dd = today.getDate();
if(dd<10) dd = '0' + dd;
str = yy + "-" + MM + "-" + dd;
textobj=document.getElementById("t5");
textobj.value=str;
textobj.select();
}