js控制輸入框獲得和失去焦點(diǎn)時(shí)狀態(tài)顯示的方法
本文實(shí)例講述了js控制輸入框獲得和失去焦點(diǎn)時(shí)狀態(tài)顯示的方法。分享給大家供大家參考。具體實(shí)現(xià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=gb2312" /> <title>邊框變色</title> <style type="text/css"> <!-- .SearchKeyword {border:1px solid #797A75;width: 202px;color: #CDCDCD;font-size:12px;} .SearchKeywordonFocus {border:1px solid #ABCD3A;width: 202px;color: #000000;font-size:12px;} --> </style> <script language="javascript"> function keywordfocus() { if (document.formSearch.keyword.value == '請(qǐng)輸入關(guān)鍵字') { document.formSearch.keyword.value = ''; document.formSearch.keyword.className = 'SearchKeywordonFocus'; } } function keywordblur() { if (document.formSearch.keyword.value == '') { document.formSearch.keyword.value = '請(qǐng)輸入關(guān)鍵字'; document.formSearch.keyword.className = 'SearchKeyword'; } } </SCRIPT> </head> <body> <form id="formSearch" name="formSearch" method="post" action=""> <input type="text" name="keyword" class="SearchKeyword" value="請(qǐng)輸入關(guān)鍵字" onFocus="keywordfocus();" onBlur="keywordblur();" /> </form> </body> </html>
希望本文所述對(duì)大家的javascript程序設(shè)計(jì)有所幫助。
- JS實(shí)現(xiàn)方向鍵切換輸入框焦點(diǎn)的方法
- javascript實(shí)現(xiàn)按回車鍵切換焦點(diǎn)
- Javascript中自動(dòng)切換焦點(diǎn)實(shí)現(xiàn)代碼
- JavaScript 回車 焦點(diǎn)切換
- JavaScript焦點(diǎn)事件、鼠標(biāo)事件和滾輪事件使用詳解
- JS實(shí)現(xiàn)密碼框根據(jù)焦點(diǎn)的獲取與失去控制文字的消失與顯示效果
- JavaScript組件焦點(diǎn)與頁(yè)內(nèi)錨點(diǎn)間傳值的方法
- 使用JS取得焦點(diǎn)(focus)元素代碼
- javascript自動(dòng)切換焦點(diǎn)控制效果完整實(shí)例
相關(guān)文章
dropdownlist之間的互相聯(lián)動(dòng)實(shí)現(xiàn)(顯示與隱藏)
dropdownlist之間的互相聯(lián)動(dòng)(顯示與隱藏)2009-11-11javascript組合使用構(gòu)造函數(shù)模式和原型模式實(shí)例
這篇文章主要介紹了javascript組合使用構(gòu)造函數(shù)模式和原型模式的方法,通過(guò)一個(gè)簡(jiǎn)單實(shí)例分析了javascript構(gòu)造函數(shù)模式與原型模式的使用方法,需要的朋友可以參考下2015-06-06js+div實(shí)現(xiàn)圖片滾動(dòng)效果代碼
本篇文章主要是對(duì)js+div實(shí)現(xiàn)圖片滾動(dòng)效果的示例代碼進(jìn)行了介紹,需要的朋友可以過(guò)來(lái)參考下,希望對(duì)大家有所幫助2014-02-02JS的執(zhí)行機(jī)制(EventLoop、宏任務(wù)和微任務(wù))
這篇文章主要介紹了JS的執(zhí)行機(jī)制(EventLoop、宏任務(wù)和微任務(wù)),具有很好的參考價(jià)值,希望對(duì)大家有所幫助。2023-01-01JS截取url中問(wèn)號(hào)后面參數(shù)的值信息
JS截取url獲取一些信息類似的文章可以在網(wǎng)上找很多,本文在重復(fù)講述一遍,有不會(huì)的朋友可以鞏固一下2014-04-04JS遠(yuǎn)程獲取網(wǎng)頁(yè)源代碼實(shí)例
獲取網(wǎng)頁(yè)源代碼的方法有很多,本文為大家介紹下使用JS是如何做到的,感興趣的朋友可以學(xué)習(xí)下哦2013-09-09