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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T06:09:42+00:00 2026-06-02T06:09:42+00:00

I add new divs with jQuery append() , and I want to be able

  • 0

I add new divs with jQuery append(), and I want to be able to get the individual content and attributes of the last div and previous ones onclick.

<!DOCTYPE html>

<script type='text/javascript'>
$(document).ready(function(){

$('#ClickDiv').live("click",function(){

IaNm=prompt("Enter Name","Name here...");
IaLang=prompt("Enter Lang","Lang here...")

$('.box:last').append('<div class="box" lang="'+IaLang+'">'+IaNm+'</div>')
})
$('.box').click(function(){
LstNm=$(this).text()
LstT=$(this).attr('lang')
$('b').html(LstNm+' : '+LstT)

})
})    


</script> 
<input type='button' value='New Div' id='ClickDiv'>
<div class='box' lang='en'>one</div>
<div class='box' lang='fr'>two</div>
<div class='box' lang='de'>three</div>

<b></b>
  • 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-02T06:09:44+00:00Added an answer on June 2, 2026 at 6:09 am

    You need to change this line:

    $('.box').click(function(){
    

    to

    $('.box').live( "click", function(){
    

    If you want to catch the click event for new elements added after the document load event

    EDIT:
    change $('.box:last').append( ... ) to $('.box:last').after(... ) so the new element will be added after the las elment and not inside of it

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

Sidebar

Related Questions

I want to add some divs using jQuery in a main div called activity-div
I'm using jQuery to dynamically add new divs containing a few fields. I'm adding
My page currently uses Slides I want to be able to add new slides
I want to dynamically add a number of DIVs to a target DIV in
New to using jQuery in Rails and can't get a div to be recognized
I want to add new obj of JSON like: 128: { Msg: [{ me:
I built a page that automatically generates new divs when you click add product.
I can't get the jquery syntax to work so that I can append 1
I'm new to jquery and ajax - just can't seem to get this to
I'm using the jQuery template engine to add dynamic DOM elements (specifically DIVs). To

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.