w.fn.init mistake when trying to read data from html Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern) Data science time! April 2019 and salary with experience Should we burninate the [wrap] tag? The Ask Question Wizard is Live!How to store arbitrary data for some HTML tagsStrip HTML from Text JavaScriptHTML-encoding lost when attribute read from input fieldSelecting all text in HTML text input when clickedRedirect from an HTML pagePassing in a global javascript array to jQuery document(ready)Jquery click trigger on Success or CompletePopup - if user enters bad input, how can I get it to error on submitHow to pass variables and data from PHP to JavaScript?socket.io chat example - trouble with form submission
Were Kohanim forbidden from serving in King David's army?
Dating a Former Employee
What is the longest distance a 13th-level monk can jump while attacking on the same turn?
Is the Standard Deduction better than Itemized when both are the same amount?
Bonus calculation: Am I making a mountain out of a molehill?
Does accepting a pardon have any bearing on trying that person for the same crime in a sovereign jurisdiction?
Is the argument below valid?
Should I discuss the type of campaign with my players?
How do I keep my slimes from escaping their pens?
When to stop saving and start investing?
How can I make names more distinctive without making them longer?
3 doors, three guards, one stone
Can a non-EU citizen traveling with me come with me through the EU passport line?
What happens to sewage if there is no river near by?
Did Xerox really develop the first LAN?
How to do this path/lattice with tikz
Is a manifold-with-boundary with given interior and non-empty boundary essentially unique?
Why is "Consequences inflicted." not a sentence?
What are the motives behind Cersei's orders given to Bronn?
Why was the term "discrete" used in discrete logarithm?
Stars Make Stars
Is it ethical to give a final exam after the professor has quit before teaching the remaining chapters of the course?
Sorting numerically
Do I really need recursive chmod to restrict access to a folder?
w.fn.init mistake when trying to read data from html
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)
Data science time! April 2019 and salary with experience
Should we burninate the [wrap] tag?
The Ask Question Wizard is Live!How to store arbitrary data for some HTML tagsStrip HTML from Text JavaScriptHTML-encoding lost when attribute read from input fieldSelecting all text in HTML text input when clickedRedirect from an HTML pagePassing in a global javascript array to jQuery document(ready)Jquery click trigger on Success or CompletePopup - if user enters bad input, how can I get it to error on submitHow to pass variables and data from PHP to JavaScript?socket.io chat example - trouble with form submission
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm trying to console log a data that will be later sent to the server:
- An array of numbers;
- Number of draws;
Everything is working with an array, but when I'm trying to console.log draws, the following message shows w.fn.init [input.draw-number, prevObject: w.fn.init(1)]
Here is the HTML I want to get data from:
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6"></td>
<td><button id="button-send_results" type = "submit">Let's win!</button></td>
</tr>
My index.js:
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number');
$('.lottery-number').each(function ()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
javascript jquery html
add a comment |
I'm trying to console log a data that will be later sent to the server:
- An array of numbers;
- Number of draws;
Everything is working with an array, but when I'm trying to console.log draws, the following message shows w.fn.init [input.draw-number, prevObject: w.fn.init(1)]
Here is the HTML I want to get data from:
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6"></td>
<td><button id="button-send_results" type = "submit">Let's win!</button></td>
</tr>
My index.js:
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number');
$('.lottery-number').each(function ()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
javascript jquery html
1
You need to add.val()
to show the value likeconsole.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
can I assign the value of this field to mydrawnumber
variable? Like thisconst drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53
add a comment |
I'm trying to console log a data that will be later sent to the server:
- An array of numbers;
- Number of draws;
Everything is working with an array, but when I'm trying to console.log draws, the following message shows w.fn.init [input.draw-number, prevObject: w.fn.init(1)]
Here is the HTML I want to get data from:
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6"></td>
<td><button id="button-send_results" type = "submit">Let's win!</button></td>
</tr>
My index.js:
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number');
$('.lottery-number').each(function ()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
javascript jquery html
I'm trying to console log a data that will be later sent to the server:
- An array of numbers;
- Number of draws;
Everything is working with an array, but when I'm trying to console.log draws, the following message shows w.fn.init [input.draw-number, prevObject: w.fn.init(1)]
Here is the HTML I want to get data from:
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6"></td>
<td><button id="button-send_results" type = "submit">Let's win!</button></td>
</tr>
My index.js:
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number');
$('.lottery-number').each(function ()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
javascript jquery html
javascript jquery html
edited Mar 22 at 8:55
Zakaria Acharki
57.1k134471
57.1k134471
asked Mar 22 at 8:38
LeoceteLeocete
10110
10110
1
You need to add.val()
to show the value likeconsole.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
can I assign the value of this field to mydrawnumber
variable? Like thisconst drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53
add a comment |
1
You need to add.val()
to show the value likeconsole.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
can I assign the value of this field to mydrawnumber
variable? Like thisconst drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53
1
1
You need to add
.val()
to show the value like console.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
You need to add
.val()
to show the value like console.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
can I assign the value of this field to my
drawnumber
variable? Like this const drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
can I assign the value of this field to my
drawnumber
variable? Like this const drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53
add a comment |
1 Answer
1
active
oldest
votes
You need to use .val()
to get the value of the input instead of the input DOM element, like :
const drawNumber = $('.draw-number').val();
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295724%2fw-fn-init-mistake-when-trying-to-read-data-from-html%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You need to use .val()
to get the value of the input instead of the input DOM element, like :
const drawNumber = $('.draw-number').val();
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
add a comment |
You need to use .val()
to get the value of the input instead of the input DOM element, like :
const drawNumber = $('.draw-number').val();
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
add a comment |
You need to use .val()
to get the value of the input instead of the input DOM element, like :
const drawNumber = $('.draw-number').val();
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
You need to use .val()
to get the value of the input instead of the input DOM element, like :
const drawNumber = $('.draw-number').val();
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
$(document).ready(() =>
$('#button-send_results').click(() =>
const userNumbersArray = [];
const drawNumber = $('.draw-number').val();
$('.lottery-number').each(function()
userNumbersArray.push($(this).val());
);
console.log(userNumbersArray);
console.log(drawNumber);
);
);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<tr>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="lottery-number" type="number" maxlength="2"></td>
<td><input class="draw-number" type="number" maxlength="6" placeholder="draw-number"></td>
<td><button id="button-send_results" type="submit">Let's win!</button></td>
</tr>
edited Mar 22 at 8:54
answered Mar 22 at 8:46
Zakaria AcharkiZakaria Acharki
57.1k134471
57.1k134471
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55295724%2fw-fn-init-mistake-when-trying-to-read-data-from-html%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
You need to add
.val()
to show the value likeconsole.log(drawNumber.val());
– Zakaria Acharki
Mar 22 at 8:44
can I assign the value of this field to my
drawnumber
variable? Like thisconst drawNumber = $('.draw-number').val();
– Leocete
Mar 22 at 8:49
Yes sure you can, check my updated answer...
– Zakaria Acharki
Mar 22 at 8:53