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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T04:59:08+00:00 2026-06-12T04:59:08+00:00

I have some jQuery that is dynamically creating a span element with a certain

  • 0

I have some jQuery that is dynamically creating a span element with a certain shape defined by css. The span elements are generated at a random x,y location on the screen and I have defined them with class=”.drawingpix”. A new span element identical to the last, except it’s location is created every second or two. I want to be able to animate the element when clicked. So far I have only be able to animate all of the elements when the body is clicked.

What I want to happen: I would like to animate the element when touched or clicked and only that one element.

This gets me nothing when in the head:

    $('.drawingpix').click(function () {
    // this is the dom element clicked?????
    var element = this;
    $(this).animate({
        height:'250px',
        width:'250px',
        'border-radius':'250px',
        '-moz-border-radius': '250px',
        '-webkit-border-radius': '250px',
        opacity: -0.2,
            }, 3000).fadeOut(0);    
});

This animates every element with the class ‘drawingpix’ when in the body but nothing when in the head.:

    $('body').click(function () {
    // this is the dom element clicked?????
    var element = this;
    $('.drawingpix').animate({
        height:'250px',
        width:'250px',
        'border-radius':'250px',
        '-moz-border-radius': '250px',
        '-webkit-border-radius': '250px',
        opacity: -0.2,
            }, 3000).fadeOut(0);    
});

I am new to jquery and javascript. I have done hours of searching and trying different things before I have posted here.

I think I need to some how get the index of the element I clicked and specify which element to animate based off of the index. Any help will be appreciated. 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-06-12T04:59:09+00:00Added an answer on June 12, 2026 at 4:59 am

    Why don’t you try delegating the event and see if that approach works for newly created elements..

     $('body').on('click', '.drawingpix' ,function () {
        // this is the dom element clicked?????
        var element = this;
        $(this).animate({
            height:'250px',
            width:'250px',
            'border-radius':'250px',
            '-moz-border-radius': '250px',
            '-webkit-border-radius': '250px',
            opacity: -0.2,
                }, 3000).fadeOut(0);    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have some jQuery code that finds elements with the shaded CSS class and
With jQuery 1.7x, I'm creating whole tables within dynamically generated tabs that have several
I have some input checkboxes that are being dynamically generated in a $.post callback
I have some javascript/jquery code that dynamically populates an unordered list with a bunch
I have some jquery code that is doing an ajax lookup and returning comma
I have some jQuery code that highlights a link when clicked, and changes the
I have some jQuery code that intercepts links clicked on a page: $(document).ready(function() {
I have some jQuery code that is having difficulty running because I'm using it
I have some jQuery code that runs fine until I add the jQuery UI
I have created some JQuery that will expand a div 'popup' on hover and

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.