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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:39:58+00:00 2026-05-28T04:39:58+00:00

I am facing a problem with jquery. I have a div with 4 drop

  • 0

I am facing a problem with jquery.

I have a div with 4 drop down list and I have an “add more” button.

When I click on “add more” button, another instance of the same div is created just above the “add more” button. I did it via jQuery append() method and it is successfully working, but my problem is that the requirement says that when i select “Other” from the drop down a text box should open where I will fill the name which is not in the list.

I can do this but when i click on “add more” and another instance is created, When I select “other” from the dynamically created listbox the text box is not created because their id becomes same and I know that id can not be same.

Similarly, in rest of the dropdown happens. If i do it by class name then creates all the text box at a time. I do not want this.
I hope you understood my problem.
Please help me and give me a solution how to manage it.

Thanks everybody and thanks stackoverflow.com

Update:

$(document).ready(function() { 
    alert('here'); 
    var content=$("#course").html(); 
    var content1=$("#emp").html(); 
    alert(content); 
    $("#add").click(function(){ 
        var n=$("#course .count").length; 
        if(n!=3){
            $("#course").append(content);
        }
        if(n==2){
            $("#add").hide();
        } 
    });
});

my html is like

dropdown1
dropdown1
dropdown1
dropdown1

add more button

when i select dynamically generated dropdown by append()…the textbox for ‘other’ not appears means unable to handle event on dynamically generated div thanks

  • 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-28T04:39:58+00:00Added an answer on May 28, 2026 at 4:39 am

    Do you perhaps want something like this?

    <html>
        <head>
        <title>Scripttest</title>
        <script type="text/javascript" src="js/jquery-1.7.1.min.js">
        </script>
        <script type="text/javascript">
            var current = 1;
    
            $(document).ready(function() {
                $("#addmore").bind('click', function() {
                    $("#somediv").append(
                        $("<select/>").attr("id", current).attr("size", 1)
                            .append('<option value="someoption">Some Option</option>' +
                                    '<option value="other">Other</option>')
                    );
                    $("<br/>").insertAfter($("#"+current));
                    current++;
                });
    
                $("#somediv").delegate('select', 'change', function() {
                    if($(this).val() == 'other') {
                        $("<textarea/>").attr("id", "tb_"+$(this).attr("id")).insertAfter($(this));
                    }
                    else {
                        $("#tb_" + $(this).attr("id")).remove();
                    }
                });
            });
        </script>
        </head>
        <body>
        <button id="addmore">Add more</button>
        <div id="somediv">
        </div>
        </body>
    </html>
    

    This would allow you to add dropdown lists and add a textarea behind it if the “Other” option is selected and remove it if it is deselected.

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

Sidebar

Related Questions

I have a problem with faking an anchor click via jQuery: Why does my
I am facing a problem with jquery and have a question. Please answer them
I am facing a problem with jquery and have a question. Please answer them
I am facing a problem in the jquery click event. My web page involves
I have code snippet like below I am facing problem when I click on
I facing a weird problem here. I already have a simple try-out for jquery
I am facing more or less the same problem described here , (i.e. I
I am relatively new to using jQuery and I have a problem with creating
I'm facing a big problem with jQuery Lightbox effect and mod_rewrite. When trying to
I'm kind of new to JavaScript and jQuery and now I'm facing a problem:

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.