I have html like
<div id="MAC_Allocation_Heading">
<span style="position:relative;left:2%;">
MAC Allocation
</span>
<span style="position:relative;left:9%;">
<label>Quantity</label>
<input type="text" style="width:40%" name="txtMACNeededAllocations"/>
</span>
</div>
Now in my .js file I have a global array as
var user_entry = [$("#MAC_Allocation_Heading input[type=text]:first")]
and inside FormValidate() I have the following code
function FormValidate() {
console.log(user_entry[0].val());
}
I run the application and entered value in text box. But I am getting console output as 'undefined'
.
If I put the array "user_entry" inside the function then am able to get the textbox value.
What is the reason?
I Would love to keep this array globally as it will be used by other functions also