How to show/hide input value on focus?

后端 未结 7 1987
隐瞒了意图╮
隐瞒了意图╮ 2021-02-06 12:44

I see this all over the web, but was wondering if anyone has the JavaScript code for the EASIEST way to show input value on blur, but hide in on focus.

7条回答
  •  无人共我
    2021-02-06 12:59

    This is what I use on my blog. Just go there and check out the source code behind.

    function displaySearchText(text){
        var searchField = document.getElementById('searchField');
        if(searchField != null)
            searchField.value = text;
    }
    

    Your input field should look something like this:

    
    

提交回复
热议问题