2016-07-19 7 views
0

Ich weiß nicht, was falsch mit meinem Code. Wenn mein Skript in jfiddle läuft, ist es in Ordnung. aber wenn es in meinem Computer (localhost) nicht funktioniert.Myscript funktioniert nicht in meinem localhost, aber wenn in jfiddle ist es in Ordnung

Hier ist meine jsfiddle: jQuery-Funktionen JSFIDDLE

Hier ist mein Skript i

<html> 
<body> 
<input id="nominal" type="text" /> 
<script> 
$(function() { 
    var money = 20000; 

    $("#nominal").on("change keyup", function() { 
     var input = $(this); 

     // remove possible existing message 
     if(input.next().is("form")) 
      input.next().remove(); 

     // show message 
     if(input.val() > money) 
      input.after("<form method=\"post\" action=\"\"><input type=\"submit\" name=\"yes\" value=\"Yes\"><input type=\"submit\" name=\"no\" value=\"No\"></form>"); 
    }); 
}); 
</script> 
</body> 
</html> 
+1

Sie müssen jquery in Ihre Datei einschließen – scrappedcola

+0

Ist jQuery in localhost enthalten? –

+0

was jquery muss ich einschließen? @ Scrappedcola –

Antwort

3

Sie die jQuery-Bibliothek enthalten müssen in meinem Computer laufen verwenden:

Setzen Sie dieses oben Sie Script-Tags :

<script src="https://code.jquery.com/jquery-3.1.0.slim.js" integrity="sha256-L6ppAjL6jgtRmfiuigeEE5AwNI2pH/X9IBbPyanJeZw=" crossorigin="anonymous"></script> 

<script> 
$(function() { 
    var money = 20000; 

    $("#nominal").on("change keyup", function() { 
     var input = $(this); 

     // remove possible existing message 
     if(input.next().is("form")) 
      input.next().remove(); 

     // show message 
     if(input.val() > money) 
      input.after("<form method=\"post\" action=\"\"><input type=\"submit\" name=\"yes\" value=\"Yes\"><input type=\"submit\" name=\"no\" value=\"No\"></form>"); 
    }); 
}); 
</script> 

Es lädt jQuery von einem CDN i auf Ihre Seite.

+0

schöne Arbeit danke –