当前位置: 代码迷 >> JavaScript >> 怎么部分高亮<input type=text>中的内容
  详细解决方案

怎么部分高亮<input type=text>中的内容

热度:429   发布时间:2012-03-02 14:40:29.0
如何部分高亮<input type=text>中的内容?
?

------解决方案--------------------
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN ">
<html>

<head>
<meta http-equiv= "pragma " content= "no-cache ">
<meta http-equiv= "Content-Type " content= "text/html; charset=gb2312 ">
<title> Document Title </title>

</head>

<body>

<input type= "text " id= "jia " value= "teststr ">
<script language= "javascript ">
var jia = document.getElementById( "jia ");
var rng = jia.createTextRange();
rng.moveStart( "character ",2);
rng.moveEnd( "character ",-2);
rng.select();
</script>

</body>

</html>
  相关解决方案