0

I have input text and some text in HTML:

<input type="text" name="user_id" id="user_id" maxlength='13' size='13'  onChange="no_user_id_change();">

<p> Your ID is: {{id from input type goes here when I type Enter in input type...}} </p>

My JavaScript:

<script>
    function no_user_id_change() {
        var userId = $("#user_id").val();      
    }
</script>

My question:

How can I get the user id from the input text when user type Enter?

Tushar
  • 85,780
  • 21
  • 159
  • 179
joshua14
  • 135
  • 2
  • 13
  • Please check the answers on the linked question. Here is the [**Demo**](https://jsfiddle.net/tusharj/rq5x7coh/) of the same answer. Note that `onchange` will not work in your case, use `key***` events. Let me know if you have any problem. – Tushar Dec 08 '16 at 03:17
  • @Tushar I know the answer if I display it on `alert`, but what I need is how to get the variable `userId` from the ` – joshua14 Dec 08 '16 at 03:20
  • `$('p').text(userId)` – 4castle Dec 08 '16 at 03:23
  • You can add a `span` element with ID inside `p` and change it's value. [**Another Demo**](https://jsfiddle.net/tusharj/rq5x7coh/1/) – Tushar Dec 08 '16 at 03:23

0 Answers0