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

  • Home
  • SEARCH
  • 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 8422545
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T03:28:47+00:00 2026-06-10T03:28:47+00:00

I am trying to remove a dynamically created element using jQuery. Here is my

  • 0

I am trying to remove a dynamically created element using jQuery.

Here is my example: http://jsfiddle.net/4uxbu/

When you click submit it highlights the required fields and displays the text This field is required. after the input. When the user clicks on the input the red box goes away, I want the text below the input to go away as well.

The message is set using the following code:

$('#' + required[i]).after('<p style="font-weight:bold;" id="' + required[i] + '_error">' + emptyerror + '</p>');

and I’ve tried to remove it with:

$('p#' + required[i] + '_error').remove();

But I can’t get it to work properly.

Required is as below

required = ["vidHeight", "title", "vidWidth", "vidLen", "thumb", "file"];

Please see the fiddle for the full code.

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-10T03:28:49+00:00Added an answer on June 10, 2026 at 3:28 am
    $('p#' + required[i] + '_error').remove();
    

    Well, required[i] doesn’t make any sense because you aren’t in a loop where i is defined anymore. Try this:

    $('#' + $(this).attr("id") + '_error').remove();
    

    See: http://jsfiddle.net/4uxbu/1/

    EDIT

    Updated to handle the case of showing multiple errors when submitting multiple times with errors: http://jsfiddle.net/4uxbu/2/

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

Sidebar

Related Questions

I am trying to remove project menu from menubar dynamically, means using code. Please
Here i am trying to dynamically add and remove the tab from uitabbarcontroller .
I am trying to remove an object from an ArrayList and here is the
I'm trying to dynamically add elements to a Cakephp form: <?php echo $javascript->link('jquery',false); ?>
I am trying to add a table row dynamically via jQuery. Everything works fine
SOLUTION removeChild: function(select) { $(select).nextAll().remove(); } I am trying to dynamically create a chain
im trying to use jquery in order to make a button remove its parent
I'm trying to dynamically create and remove items from a list, it works just
I am trying to dynamically create HTML elements using the DOM. The elements are
on my MVC3 razor page,I am trying to dynamically add a textbox with click

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.