高亮显示选中的文本输入框

2008-12-26 08:40:57 | 【

本脚本实现了用户在点击表单内的文本框时实现文本框的高亮显示,在很长场合非常有用,代码简短,调用方便

查看演示页面 View Demo

下载:
点击这里下载全部代码

在网页<head>区添加以下代码

<style type="text/css">

	body{
		background-repeat:no-repeat;
		font-family: Trebuchet MS, Lucida Sans Unicode, Arial, sans-serif;
		height:100%;
		background-color: #FFF;
		margin:0px;
		padding:0px;
		background-image:url('http://www.sharejs.com/images/logo.gif');
		background-repeat:no-repeat;
		padding-top:85px;
	}
	
	.textInput,textarea{	/* General style for my inputs when they're not highlighted */
		width:300px;	
		font-family:arial;
		background-color:#FFFFFF;
		border:1px solid #000;
	}
	
	
	.inputHighlighted{	/* Highlighting style */
		background-color:#317082;
		color:#FFF;
		width:300px;
		border:1px solid #000;
	}
	
	
	</style>
	<script type="text/javascript" src="js/highlight-active-input.js">
                  
        /*****************************************************
         *  Share JavaScript (http://www.ShareJS.com)
         * 使用此脚本程序,请保留此声明
         * 获取此脚本以及更多的JavaScript程序,请访问 http://www.ShareJS.com
         ******************************************************/
    
	</script>



.textInput,textarea可以高亮显示文本框的CSS定义,在这里我们使用白色的背景和黑色的边框来标注这些文本框。.inputHighlighted定义了文本框获得焦点后的高亮样式

初始化脚本
要初始化程序,需要在HTML代码的最后加上以下代码

<script type="text/javascript">
// Initialize the input highlight script
initInputHighlightScript();
</script> 

下载"高亮显示选中的文本输入框"

  • 本地下载
  • 本地下载2

相关资源