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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T22:40:24+00:00 2026-06-07T22:40:24+00:00

I have been working on a project recently and have been required to learn

  • 0

I have been working on a project recently and have been required to learn jQuery to do it. Not such an easy thing to learn for a beginner ha. Anyway I have been trying to have a few div tags that are switched between depending on which one the user has clicked on.

The first one, “Add field” should switch to a div that contains a button to add a new field. Now instead of putting a large amount of code here I instead put it into http://jsfiddle.net/9acEk/8/ so you could see a working example, or rather not working. My problem is that when I change a tab and click back on “Add field” tab the buttons no longer work. the page opens with a button that when clicked adds a text box. However even if I just click on the “Add field” tab the button no longer does anything, I have used alert boxs to display the code and it is exactly the same. I have no idea why this does not work after clicking on the tab, it makes no sense to me as the code, as mentioned, is exactly the same.

Apologies if the question makes no sense, any questions on it just ask me and I shall do my best to clear it up. Thanks a lot in advance to any help given, it is appreciated.

EDIT:
It seems the jsfiddle does not work(Sorry very new to that as well) so I shall instead put code here.

    <html>
<body>
    <table width ="100%" alight="right">
        <td width ="51.5%"></td>
        <td> <div id="addField" class="tabOptions">Add field</div></td>
        <td><div id="fieldProperties" class="tabOptions">Field Properties</div></td>
        <td> <div id="formProperties" class="tabOptions">Form Properties</div></td>
    </table>
    <hr>

    <table align ="left"style="background-color: white" width="100%">
        <tr>
        <tr>
        <div id="formName" class="formDetails">
                <h2>Untitled</h2>
                <h4>This is your form description</h4>
        </div>
    </tr>
    <td width ="50%">
        <ul id ="firstColumn">
            <div id="identifier">
            </div>
        </ul>
    </td>
    <td>
        <ul id ="secondColumn" width="5%">
            <div id="placeholder">
                <div id="mainPanel">
                    <li><input type="button" class="formCreationButton" id="textAdd" value="Single line text" /></li>

                </div>
            </div>
        </ul>
    </td>
    <tr>
</table>

​

jQuery

     var counter = 1;
var textAreaCounter = 1;
var textBoxCounter = 1;
var tempStorage = $('div#placeholder').html();



$(document).ready(function() {

    $(".formDetails").live('click','div',function(){
        var divID = this.id;
        alert(divID);
        alert(document.getElementById(divID).innerHTML);
    });

    $(".container").live('click','div',function(){

        var divID = this.id;
        if(divID != ""){
            alert(divID);
            var content = document.getElementById(divID).outerHTML;
            // alert(content);
            var text = document.getElementById(divID).innerHTML;
            alert(text);

            var textboxId = $('div.container')
            .find('input[type="text"]')[0]
            .id;
            $('div#placeholder').html(content);
        }
        else{

        }

    });

    $("#addField").live('click','div',function(){
        $('div#placeholder').html(tempStorage);
    });
    $("#fieldProperties").live('click','div',function(){
        var content = "<p>Content of fields should be here</p>";
        $('div#placeholder').html(content);
    });
    $("#formProperties").live('click','div',function(){
        var content = "<p>Content of form should be here</p>";
        $('div#placeholder').html(content);
    });
    $('#textAdd').click(function() {
        var newdiv = document.createElement('div');
        newdiv.innerHTML = "Textbox " + textBoxCounter + " <br><div id='container " + textBoxCounter +      "' class='container'><li><input type='text' value='TEXT' id='textBox " + textBoxCounter +"' name='textBox " + textBoxCounter +"')'></li></div></br>";
        document.getElementById("identifier").appendChild(newdiv);
        textBoxCounter++
        counter++;
    });
});​
  • 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-06-07T22:40:26+00:00Added an answer on June 7, 2026 at 10:40 pm

    Change

    $('#textAdd').click(function()
    

    to

    $('#textAdd').live('click',function() {
    

    and it works fine .. working example here

    A couple of things ….

    You are using a very old version of jQuery – 1.4.4. I suggest that if your going to learn something new you learn the latest release …. and in that latest release the live() function has been replaced by on() – so your code would look like this :

    $(document).on('click','#textAdd',function() {
    

    Where document is any parent element present on page load

    Working example here

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

Sidebar

Related Questions

On one project we have been working on recently, we have in essence totally
Recently I have been working on a project where, among other things, we want
I have been working on a project recently where a Player can create a
On a rails project that I know to have been working as recently as
So recently I have been working on phonebook project that uses Binary Search Tree.
I have been working with a small project recently which involves Struts 2 and
I have recently been working with someone on a project that is very ajax
I have been recently working on an easy to use Syntax Highlighting system for
I have recently been working on a ASP.NET project for a client. The project
I have been working on a project in C# (.net4). Project pretty much allows

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.