Jquery autoSearch watermark

I use the jQuery plugin wordFilter: http://people.apache.org/~gmonroe/wordFilter/index.html , which gives an autosave function that allows you to automatically filter the list of elements based on the text typed into the text box.

This works fine, but I was also hoping to have a text_field watermark there if no text was entered. this text, unfortunately, causes an automatic search. Of course, I don’t want this, I want to be ignored until the user types.

Does anyone have any experience using a text box such as autosave with a watermark?

+3
source share
2 answers

. , , .

:

CSS:

.autoSearch {
    color: #999;
}  

HTML: . searchclass ,

<input type="text" class="field autoSearch" searchclass="assign-filter" id="assign-search"/>

Javascript: autoSearch .

$('.autoSearch').click(function() {
        $(this).val('');
        $(this).removeClass('autoSearch');
        $(this).autoSearch('.'+$(this).attr('searchclass')); 
    });
+1

, , , , .

$('.autoSearch').focus(function() {
        $(this).val('');
        $(this).removeClass('autoSearch');
        $(this).autoSearch('.'+$(this).attr('searchclass')); 
    });
0

Source: https://habr.com/ru/post/1705669/


All Articles