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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T15:29:29+00:00 2026-05-31T15:29:29+00:00

I am new in jQuery and here is my problem: I have a function

  • 0

I am new in jQuery and here is my problem:

I have a function that triggers an animation (carousel) and performs the following:

  • Inserts a div before the default div (class=”template”) with the
    desired content
  • Animates the two divs and brings the new div inview
  • Removes the old div and its contents

The function works only for the first time.
I suspect that jquery does not recognise the remaining div, even if it has the same class with the old div.
How can I tell jQuery to grab the new div and perform the same task?

The function works in a page that is loaded via ajax in a div with id=”ajax_content”

Here is the HTML:

<div id="prev" class="pers_arrow"></div>    <!-- Left Arrow -->

<div id="pers_content">

<div id="template_container" class="cur_temp">  <!-- Template Container (850px or 1700px width) -->



    <div class="template"> <!-- The div that holds the default content, after the function execution is removed and replased from the new div with the same class -->
        <div id="template_loading"></div>   <!-- Loading template icon -->
        <div id="pers_image">
            <img src="images/user.png" alt="" />
        </div>
        <div id="pers_details">
            <h1>Μερκούρης Καραγιάννης</h1>
            <p>
            Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
            </p>            
        </div>
    </div>

</div>

Here is the script:

var ajax_content = $('#ajax_content');
var prev = $('#prev');
var pers_arrow = $('.pers_arrow');

var temp = function() {
    var ajax_content = $('#ajax_content');
    var prev = $('#prev');
    var template_loading = $('#template_loading');
    var template_container = $('#template_container');  
    var template = $('.template');
        var first_temp = template.filter(':first');
        var last_temp = template.filter(':last');

    var htmlEx = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in mattis elit. Aliquam egestas justo aliquet risus tempus porttitor. Vivamus vel ultricies dolor. Lorem ipsum dolor sit amet, consectetur adipiscing elit. Integer in mattis elit. Aliquam egestas justo aliquet risus tempus porttitor. Vivamus vel ultricies dolor.";

    template_loading
        .fadeIn()
        .queue(function() {
            template_container.attr('class', 'cur_prev')        
            template.before('<div class="template">' + htmlEx + '</div>')
                .queue(function() {
                    template_container.animate({"margin-left" : "0"}, 400, 'easeOutExpo')
                        .queue(function() {
                            template_loading.fadeOut();
                            last_temp.remove();
                            template_container.attr('class', 'cur_temp');                                   
                            $(this).dequeue();
                        });
                    $(this).dequeue();
                });
            $(this).dequeue();
        });
};

ajax_content.on("click", prev, temp); 
  • 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-31T15:29:30+00:00Added an answer on May 31, 2026 at 3:29 pm

    You should delegate event handling to another element

     $(document).on("click",  prev, temp);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple function in jQuery that creates new elements in the DOM.
I have application that brings response via Ajax and creates 5-20 new jQuery click
Now here's a fun problem. I have an object array as the following: objRequests
I am fairly new to jQuery and I have this overlay window that pops
I'm new to jquery and having a problem using .delegate() to bind a function
Here's my situation: i have a dialog form that inserts some data on my
How can i achieve that I get jQuery-Intellisense in the following code example? function
I have a problem with the animate() function in jQuery: $(this).addClass(activeClass).animate({ position: 'absolute' width:
I am brand new to Jquery and have run into something that if answered
I am using the jQuery form validation plugin. The problem I have is that

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.