Reputation: 167
i don't know what wrong with my code. if my script running in jsfiddle it's fine. but if in my computer(localhost) it's not working.
Here's my jsfiddle: JSFIDDLE
Here's my script i running in my computer
<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>
Upvotes: 0
Views: 58
Reputation: 1087
You need to include the jQuery library to use jQuery functions:
Put this above you 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>
It will load jQuery from a CDN into your page.
Upvotes: 3