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 3216208
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:16:02+00:00 2026-05-17T15:16:02+00:00

Here is a plug-in that binds a click event on an element, which generates

  • 0

Here is a plug-in that binds a click event on an element, which generates a container with a <textarea> and then i bind a keypress event on this new <textarea>, all is ok, but inside the keypress handler i can only get the state of text().length from when the initial click happened.

How do i get the onKeyPress function to get the state of the <textarea> at the time the keypress happened?

$.fn.pluginTemp = function(options){
    var defaults = {
            editContainer:"<div class='editContainer'><textarea></textarea></div>",
            maxChar:20,
            onKeyPress:function(){
                    console.log($(".editContainer>textarea").text())
               }

     }
    var options = $.extend(defaults,options); 
    return this.each(function(i,e){
        var el = $(e), initText
        el.bind("click", function(){
            initText = el.text();
            el.parent().append(options.editContainer);
            el.parent().find(".editContainer>textarea").html(initText);
              // isn't this function remembering the state for when its is defined?  which is on keypress?          
               return function(){
                el.parent().find(".editContainer>textarea").bind("keypress",options.onKeyPress)
            }()

        })
    })
}
  • 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-17T15:16:03+00:00Added an answer on May 17, 2026 at 3:16 pm

    I got the problem,

    Instead of getting the current value via the .html() method,
    I used .val()

    Here is why:
    The .html() method when used on a <textarea> looks only at the initial state of the textarea, When you have .val() it samples the most current value.

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

Sidebar

Related Questions

I'm developing an Eclipse plug-in and I have a problem which is reproduced here:
Here is a query string that I use to plug into a form: team,site,week,day,date,o:team,line,points,o:points@season=2011
If you visit here: http://www.egyptevakantie.nl/dahab , click on the andere plaatsen tab, and then
I've created an MSI windows installer that installs a plug-in which I wrote for
So here's the problem. I'm writing some StyleCop plug-in assemblies for use at the
Here is the code in a function I'm trying to revise. This example works
I've created a plug-in that duck-punches the jQuery Ajax function. One problem that I
Here is my problem: I'm developing a system that can be polled to retrieve
I installed Xcode 3.2.3 and the symbolicatecrash console utility that used to live here:
I'm trying to develop a JQuery plug-in that will access an outside XML feed

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.