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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:23:33+00:00 2026-05-28T06:23:33+00:00

I have a textarea where user can edit some text and it accepts HTML.

  • 0

I have a textarea where user can edit some text and it accepts HTML. In the system, we can add a multimedia file to be added in the textarea. But when someone unlink the multimedia, i need to check if there is any of it in the textarea, remove it and put back on textarea.

So:
I got a textarea like this

<textarea id="edNew-body" class="apply-jHtmlArea" style="width:550px;height:250px;"></textarea>`

When i add some multimedia, it comes like this for e.g.:

<audio src="whatever url" controls="controls" class="multimedia_666007" style="display: block; margin: 5px auto 10px; width: 320px; height: 35px; background-color: rgb(227, 227, 227);">-AUDIO-No support for HTML5</audio>`

So, when i remove the multimedia, i need to get all html inside the textarea and remove all elements with class=multimedia_NNNNN where NNNN will be a number.

I tried the following: Made a JSFiddle with below code

 dataId = '666007'; //not fixed, will come from somewhere from system
 var $currentHtml = $($("#edNew-body.apply-jHtmlArea").val());
 $currentHtml.find('.multimedia_'+dataId).remove(); //get all but ignore elements with this class
 $("#edNew-body.apply-jHtmlArea").val($currentHtml.html()); //put Html back without elements

I have tried the answer from those questions below but they only work on those issues. When i try adapt, i always end with [object Object] or just the first text ‘something’ without any html.

JQuery, remove element from string

String to jQuery object, how to remove elements

Remove element from html string in JQuery

Reading the answers i’ve learned that i need to use find because since it’s user input, it can be or not nested in something (so i can’t use remove('.classhere'))

  • 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-28T06:23:34+00:00Added an answer on May 28, 2026 at 6:23 am

    If you place the HTML in a container, then .find() will be able to search all the elements (since it never looks at elements at the top level).

    Also, since .html() only gives you nested HTML content, putting it in a container will allow .html() to give you back the entire modified HTML content.

    $('#rmv').click(function(e){
        e.preventDefault();
        var dataId = '666007'; 
    
          // Put the markup in a new container
        var $currentHtml = $('<div>').append($("#edNew-body.apply-jHtmlArea").val());
    
          // .find() will now be able to search through all the markup you added
        $currentHtml.find('.multimedia_'+dataId).remove();
    
          // .html() will now give you back all the markup (though modified)
        $("#edNew-body.apply-jHtmlArea").val($currentHtml.html()); 
    });
    

    http://jsfiddle.net/jR5bc/

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

Sidebar

Related Questions

I have a text area in HTML where the user can enter text, but
I have a textarea tag that has text I want a user to edit.
I have textarea in my site(link shortening site) i want to user enter some
I have an HTML textarea element. I want to prevent a user from entering
I have a textarea that I'm able to edit with the jeditable plugin but
I have a textarea in an ASP.NET MVC Application where the user can type
I have a JS file CharacterSelection where a user can select an avatar and
From the database, I load some data that user can edit. Let's say we
I export a variable to a textarea via var_export ($schools,true) so user can edit
I have a textarea in which the user enters the following data: Paul:Nine, Rome

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.