Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7496095
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T18:28:40+00:00 2026-05-29T18:28:40+00:00

I have created a keyup() function the code is here $(document).ready(function() { var scntDiv

  • 0

I have created a keyup() function the code is here

$(document).ready(function() {
    var scntDiv = $('#add_words');
    var wordscount = 1;
    $(document).keyup(function(e) {

        var key = (e.keyCode ? e.keyCode : e.which);
        if (key === 32) {
            wordscount++;
            $('.input1').append('<p>stop touching your keyboard</p>');
            $('<div class="line">Word ' + wordscount + '<input type="text" class="input' + wordscount + '" value="' + wordscount + '" /><a class="remScnt">Remove</a></div>').appendTo(scntDiv);
            i++
            return false;
        }
    });
});

<div id="add_words">
    <div class="line">Word 1<input class="input1" type="text" value="1" /></div>
</div>

which is working fine but whenever I press spacebar adding new input field.
the problem is that I wouldn’t able to type long words with space(coming a lot of input field)

eg:- when type “my hello world” shows two input field. Actually I need one extra field.

my question is that is there any option keyup() function working only on first time in the same field

If you know could you help me please

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T18:28:43+00:00Added an answer on May 29, 2026 at 6:28 pm

    I think this is what you serach for

    $(document).ready(function() {
        var scntDiv = $('#add_words');
        var wordscount = 1;
    $("#add_words").on("keyup","input[type='text']",function(e) { // Set the eventhandler to the inputs
    
            var key = (e.keyCode ? e.keyCode : e.which);
            if (key === 32) {
                if($(this).attr("data-isused")!="true"){ // Check if THIS textbox have append a new textbox?
                $(this).attr("data-isused","true"); // Mark that this textbox has append a new one
                wordscount++;
                $('.input1').append('<p>stop touching your keyboard</p>');
                $('<div class="line">Word ' + wordscount + '<input type="text"     class="input' + wordscount + '" value="' + wordscount + '" /><a class="remScnt">Remove</a>    </div>').appendTo(scntDiv);
            //i++ Ignore this, couse its not declared
            return false;
            }
        }
    });
    

    });

    JS Fiddle:
    http://jsfiddle.net/pURVS/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi I have some code.. $(document).ready(function() { $(#inputPageName).keyup(function () { var value = $(this).val();
I have the following code to count and trigger some functions using jQuery: jQuery('#input_guideName').keyup(function(e)
I have created a foreign key (in SQL Server) by: alter table company add
I have a page in which a set of text boxes are created based
I have played with: https://github.com/experteer/autocompleteTrigger/ as following: (function ($, window, document, undefined) { $.widget(ui.autocompleteTrigger,
Have created a stored procedure which is utilised for monitoring purposes of a website.
Have created a c++ implementation of the Hough transform for detecting lines in images.
I have created a template for Visual Studio 2008 and it currently shows up
I have created a custom dialog for Visual Studio Setup Project using the steps
I have created a PHP-script to update a web server that is live inside

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.