日期:2014-05-16  浏览次数:20399 次

如何部分高亮<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>