修改文本框的颜色-光标的显示明显详解编程语言

我们的页面是使用光标跳转的,但是光标在文本框中不是很明显,有时候会看不清光标在那个域中,所以现在增加对文本域的标识,进入域变色,离开的时候再变回来,

在页面中增加下面的控制实现

 

 

<script type="text/javascript"> 
window.onload = function (){ 
	var inputs = document.getElementsByTagName("input"); 
	for (var i=0,j=inputs.length;i<j;i++){ 
	var ccc = inputs[i].type; 
		if(inputs[i].type == "text"){  
	       inputs[i].change = false; 
	       inputs[i].onfocus = inputs[i].onblur = changeBgColor; 
		} 
	} 
} 
 
function changeBgColor(){ 
 	if(this.type == "text"){ 
		this.style.background = this.change?"#fff":"#0099CC"; 
		this.change = !this.change;	 
	} 
} 
</script>

 

原创文章,作者:ItWorker,如若转载,请注明出处:https://blog.ytso.com/13667.html

(0)
上一篇 2021年7月19日
下一篇 2021年7月19日

相关推荐

发表回复

登录后才能评论