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;








1















I'm trying to console log a data that will be later sent to the server:



  1. An array of numbers;

  2. 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);
);

);









share|improve this question



















  • 1





    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











  • Yes sure you can, check my updated answer...

    – Zakaria Acharki
    Mar 22 at 8:53


















1















I'm trying to console log a data that will be later sent to the server:



  1. An array of numbers;

  2. 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);
);

);









share|improve this question



















  • 1





    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











  • Yes sure you can, check my updated answer...

    – Zakaria Acharki
    Mar 22 at 8:53














1












1








1








I'm trying to console log a data that will be later sent to the server:



  1. An array of numbers;

  2. 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);
);

);









share|improve this question
















I'm trying to console log a data that will be later sent to the server:



  1. An array of numbers;

  2. 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






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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











  • Yes sure you can, check my updated answer...

    – Zakaria Acharki
    Mar 22 at 8:53













  • 1





    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











  • 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













1 Answer
1






active

oldest

votes


















1














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>








share|improve this answer

























    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
    );



    );













    draft saved

    draft discarded


















    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









    1














    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>








    share|improve this answer





























      1














      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>








      share|improve this answer



























        1












        1








        1







        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>








        share|improve this answer















        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>






        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Mar 22 at 8:54

























        answered Mar 22 at 8:46









        Zakaria AcharkiZakaria Acharki

        57.1k134471




        57.1k134471





























            draft saved

            draft discarded
















































            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.




            draft saved


            draft discarded














            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





















































            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







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현