Question

I have a page with several JQuery autocompletes. I have implemented a button to clear all selected values, but it does not work... I have tried to set $(...).text(""); but it does not work. Firebugs fails on the line and does not throw any error message. It quits the function.

What is the right way to clear the selected value of JQuery autocompletes, from code?

Was it helpful?

Solution

Try using $(...).attr("value","");

Hope it works!! Sorry if i have misunderstood the question.

OTHER TIPS

You should use:

$('selector').autocomplete('close').val('');

This will also reset the current search of the autocomplete (in addition to clearing the input).

You should use this one, it'll work

$("selector").autocomplete({
            source: ,
            delay: 200,
            minLength: 3,                
            select: function (event, ui) {                    
               ui.item.value = "";  // it will clear field 
                return false;
            }
        });

Try this,

$("selector").autocomplete({
                source: ,
                delay: 200,
                minLength: 3,                
                select: function (event, ui) {                    
                    $(this).val() = "";
                    return false;
                }
            });
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top