JS Keyboard Event Monitor Enter, and then disable the current input edit, create the input, but the following code can only be monitored once, the second cannot be monitored.

Source: Internet
Author: User

Workaround 1. Encapsulate the actions that generate tags and add events into Method 2. Add Event 3 to the label. The most important point is to generate the tag and add the current JS return monitor $ (". Out:last"). focus ();     var  i = 0;    var myfun = function  ()  {         i++;        var keyCode  = event.keycode;        if  (keyCode ==  ")   {            var html =  "<span ><input type= ' text '  class= ' out '  value= ' " + i + " '  /></span > ";            if  ($ (". Out:last "). Val (). Trim ()  !=  "")  {                 $ (". Out:last"). Removeclass ("Out"). attr ("Disabled",  "disabled"). Parent (). After (HTML);                  $ (". Out:last"). Focus ();                 $ (". Out"). KeyDown (Myfun);             } else {                 alert ("Please enter a label");             }          }    };

$ (". Out"). KeyDown (Myfun);

The above is for reference only, there is a better solution please provide.

JS Keyboard Event Monitor Enter, and then disable the current input edit, create the input, but the following code can only be monitored once, the second cannot be monitored.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.