Dynamically add or remove text boxes and obtain text box values

Source: Internet
Author: User

A long time ago, Insus. NET has implemented "click a button to generate a new text box, enter values, and then get" http://www.cnblogs.com/insus/archive/2012/09/24/2700658.html. I want to practice it again today, but it is implemented using jQuery IN THE asp.net mvc environment. Do not use web controls.

Create a view operation:



Put two buttons and two Div labels in the view. When the dynamic loading container is used:



Add jQuery references to the View:

<Script src = "~ /Scripts/jquery-2.1.0.js "> </script>


Add and remove text boxes:



Line #37 of the Code above. When you click to add a text box, the structure of the generated html is as follows:



Get the value of the text box:



Let's take a look at the real-time Demo:



Related Article

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.