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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:40:19+00:00 2026-06-03T13:40:19+00:00

I am really confusing, I have a js file with a lot of scripts,

  • 0

I am really confusing, I have a js file with a lot of scripts, all of them worked correctly and I just add new lines:

$('.RemoveE').click(function () {
    alert('yap');
});

but that not worked, I test it with firebug and every things is OK, also I try another browsers that not worked either, I must mention that I add new button with CSS class ="ReomoveE button red" by script, this is a part of my js include new lines and add button:

// <reference path="../jquery-1.7.1.js" />
$(document).ready(function() {

    $('.RemoveE').click(function() {
        alert('yap');
    });

    //Add new Addable div
    $('.AddNewE').click(function() {

        var Target = $('.Addable:first');
        var TargetId = $(Target).attr('id');
        var Count = $('.Addable#' + TargetId).size();
        var CloneTarget = $(Target).clone();
        CloneTarget.find('input').val('');
        CloneTarget.insertAfter('.Addable:last');
        var TargetName = $(Target).find('input').attr('name');
        var CloneName = TargetName + '[1]';
        TargetName = TargetName + '[0]';
        $(Target).find('input').attr('name', TargetName);
        $(Target).find('span[class*="field-validation"]').attr('data-valmsg-for', TargetName);
        $(CloneTarget).find('input').attr('name', CloneName);
        $(CloneTarget).append($('<input type="button" class="RemoveE button red" value="remove" />'));

        (function($) {
            $.fn.updateValidation = function() {
                var form = this.closest("form").removeData("validator").removeData("unobtrusiveValidation");
                $.validator.unobtrusive.parse(form);
                return this;
            };
        })(jQuery);

        $(Target).updateValidation();
        $(CloneTarget).updateValidation();
    });
    ...
});​

So what do you think? Where is the problem, why all functions worked correctly, but this new one no?

  • 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-03T13:40:20+00:00Added an answer on June 3, 2026 at 1:40 pm

    You added the handler before the element existed:

    $('.RemoveE').click(function() {
        alert('yap');
    });
    
    //then later
    
    $(CloneTarget).append($('<input type="button" class="RemoveE button red" value="remove" />'));
    

    Try:

    Adding the handler on creation:

    var newInput = $('<input type="button" class="RemoveE button red" value="remove" />')
    
    newInput.click(function(){
        alert('yap');
    });
    
    $(CloneTarget).append(newInput)
    

    or delegation with on()

    $(parent_of_RemoveE).on('click','.RemoveE',function() {
        alert('yap');
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having a really confusing problem. I have a UIWebView that is contained within
I have a really weird and confusing error. Here is my code: {if="$pjax ===
I have this code to load a config file and read all the values
This is really confusing me, it just does not want to work. I did
I've just come across some code that's confusing me slightly; there are really 2
My js.erb file won't appear in Rails 3.1.2 and it's really confusing me. I'm
Hello all Windows Mobile Experts! I have really drowned in the world of developing
I have some confusion. Not really a bug or issue I am facing. I
This is really confusing me as I'm not doing anything with Strings. This is
The following code seemed really confusing to me since it provided two different outputs.The

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.