Just before I jump from the roof :-)

Need some help here - autosuggest jQuery:

<!DOCTYPE html>

            <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
            <script type="text/javascript">
                $(function() {
                    var timer;
                    $("#txt1").on('keyup', function(e) {
                        var self=this;
                        if (self.value.length===0) {
                            timer = setTimeout(function() {
                                    type: "GET",
                                    url: "gethint.asp?q="+self.value,
                                }).done(function( hint ) {
                            }, 500);
            <h3>Start typing a name in the input field below:</h3>
            <form action=""> 
                First name: <input type="text" id="txt1" />
            <p>Suggestions: <span id="txtHint">... some content ...</span></p> 


One small problem: I enter some text, but change my mind and remove everything.
When the text is removed this field appears without content:
<span id="txtHint">... some content ...</span>

Because of this code:

But I want it to continue to say "... some content ..." even after I've removed the text in the text box.

Can be done with this method, but then there will be a lot of unnecessary coding:
$("txtHint").text('... some content ...');

Perhaps poorly explained, but it is still someone who can help me?

Best regards. Vetle

5 Years
Discussion Span
Last Post by pritaeas

<span id="txtHint">... some content ...</span>

Yes, I understood. But I do not want to write content 2 times (see my thread above).

If I write a lot of content inside:
<span id="txtHint"> ... some content ... </ span>

... I must also write the same here:
$ ("txtHint"). text ('... some content ...');

Which is unnecessary coding ....

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.