獲得焦點時,文本框內值隱藏,失去焦點時,文本框內的值顯示

javascript代碼:
function clearText(thefield){
if (Element.readAttribute(thefield, "defaultvalue")==thefield.value){
thefield.value = ""
thefield.style.color="black"
}
}

function refill(thefield){
if(thefield.value==""){
thefield.value=Element.readAttribute(thefield, "defaultvalue")
thefield.style.color="#ccc"
}
}

ruby代碼:

<label for="search_query">Search</label>
<%= text_field_tag 'q', "Search", {:id=>"search_query", :class=>"text_field", :defaultValue=>"Search",:οnfοcus=>'clearText(this)', :style=>'color:#ccc;', :οnblur=>'refill(this)'} %>



發佈了12 篇原創文章 · 獲贊 169 · 訪問量 30萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章