+ 1
I want To get The Value that User Entered in the input box using jquery
Hi!
4 Antworten
+ 2
$("#myInputBox").val()
+ 2
Post your code?
If you're calling that function before you enter anything in the input box, then it'll return empty because it's empty. So you'll want it to check the val() of the input box when the user clicks 'submit' or 'ok' or whatever is being used.
If you further explain your situation, I can tell you exactly how to do it. If you can post your code, that'll work even better.
+ 2
https://code.sololearn.com/WP3nMrCOOQjg/#html
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
<script src="https://code.jquery.com/jquery-3.1.1.js"></script>
</head>
<body>
<input id="myInputBox" type="text"/>
<button id="myButton" > Ok </button>
<div id="myDiv"></div>
</body>
</html>
<script>
$(function() {
$('#myButton').click(function(){
$('#myDiv').text("Input Value: " + $('#myInputBox').val());
});
});
</script>
+ 1
returns emty