JS文本獲得焦點(diǎn)清除文本文字的示例代碼
如下所示:
<!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>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>無標(biāo)題文檔</title>
<style type="text/css">
.clearFieldBlurred{
color:#ccc;
font-style:italic;
font-weight:normal;
width:150px;
}
.clearFieldActive{
color:#4e4e4e;
font-weight:bold;
width:150px;
}
</style>
<script type="text/javascript">
function clearFiled(){
var bbb=document.getElementById("bbb");
if(bbb.value=="bbb"){
bbb.value='';
bbb.className='clearFieldActive';
}
}
window.document.onmousedown=function(){
var bbb=document.getElementById('bbb');
if(bbb.value==""){
bbb.value='bbb';
bbb.className='clearFieldBlurred';
}
}
</script>
</head>
<body>
<input type="text" id="aaa" value="aaa" class="clearFieldBlurred" onfocus="if(this.value=='aaa'){this.value='';this.className='clearFieldActive';}" onblur="if(this.value==''){this.value='aaa';this.className='clearFieldBlurred';}"/>
<br />
<input type="text" id="bbb" value="bbb" class="clearFieldBlurred" onclick="clearFiled()" />
</body>
</html>
- JS實(shí)現(xiàn)Enter鍵跳轉(zhuǎn)及控件獲得焦點(diǎn)
- js 上下左右鍵控制焦點(diǎn)(示例代碼)
- 使用js判斷控件是否獲得焦點(diǎn)
- 通過JS來判斷頁面控件是否獲取焦點(diǎn)
- js 判斷控件獲得焦點(diǎn)的示例代碼
- js/jquery獲取文本框輸入焦點(diǎn)的方法
- js設(shè)置文本框中焦點(diǎn)位置在最后的示例代碼(簡單實(shí)用)
- js實(shí)現(xiàn)文本框中焦點(diǎn)在最后位置
- js實(shí)現(xiàn)獲取焦點(diǎn)后光標(biāo)在字符串后
- js控制輸入框獲得和失去焦點(diǎn)時(shí)狀態(tài)顯示的方法
- js仿土豆網(wǎng)帶縮略圖的焦點(diǎn)圖片切換效果實(shí)現(xiàn)方法
- JS+CSS實(shí)現(xiàn)淡入式焦點(diǎn)圖片幻燈切換效果的方法
- js焦點(diǎn)文字滾動(dòng)效果代碼分享
相關(guān)文章
基于Bootstrap的Java開發(fā)問題匯總(Spring MVC)
這篇文章主要為大家匯總了基于Bootstrap的Java開發(fā)問題,具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2017-01-01純javascript實(shí)現(xiàn)四方向文本無縫滾動(dòng)效果
本文主要給大家分享了使用純javascript實(shí)現(xiàn)的可控制的四方向文本無縫滾動(dòng)的代碼,效果非常不錯(cuò),有需要的小伙伴可以參考下。2015-06-06JavaScript中判斷頁面關(guān)閉、頁面刷新的實(shí)現(xiàn)代碼
這篇文章主要介紹了JavaScript中判斷頁面關(guān)閉、頁面刷新的實(shí)現(xiàn)代碼,在一些特殊的場合中會用到這個(gè)技術(shù),需要的朋友可以參考下2014-08-08JS組件Bootstrap實(shí)現(xiàn)下拉菜單效果代碼
這篇文章主要為大家詳細(xì)介紹了JS組件Bootstrap實(shí)現(xiàn)下拉菜單效果代碼,感興趣的小伙伴們可以參考一下2016-04-04