Input <input> data is not getting from 2nd time

In ionic, i had taken

HTML code:

<input maxlength="1" autocomplete="off" type="password" id="Enewid1" >

Javascript code:

var pin = $('#Enewid1').val();

ISSUE:
Here the issue is am getting the value from “pin” for 1st time
But from the 2nd time am getting the empty string value.

I had also tried by using the value="" attribute in element but it’s not working

Hello @RajaJakkampudi. Please tell me when are you getting value? On some button click or as soon as the value of field changes?

Hello, @umerf6455 (Farooq) thanks a lot for you are response.
Am getting the value by clicking on button like below

<button class="waves-effect waves-light btn-large" (click)="showPIN()" id="submitBtn">submit</button>

Hi @RajaJakkampudi, Sorry for late reply. I hope that you can achieve your functionality as follows, Please let me know if you have any confusion:

HTML:

	<input maxlength="1" autocomplete="off" type="password" id="Enewid1" >
	<button class="waves-effect waves-light btn-large" onclick="showPIN()" id="submitBtn">submit</button>

JAVASCRIPT:

	function showPIN()
	{
		var pin = document.getElementById("Enewid1").value;
		alert(pin);
	}

I have added alert just to check the value, you can remove it later.
Cheers!!!