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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:35:32+00:00 2026-06-15T21:35:32+00:00

So basically my div generates like this: <div class=test className>content</div> <div class=test className>content</div> <div

  • 0

So basically my div generates like this:

<div class="test className">content</div>
<div class="test className">content</div>
<div class="test className">content</div>
..
<div class="test className">content</div>

and I’m trying to remove duplicated divs and keep last one only! any quick ideas? 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-15T21:35:33+00:00Added an answer on June 15, 2026 at 9:35 pm

    A quick idea based on your provided markup.

    var $div = $('div.test.className:contains(content)');
    
    if ($div.length > 1) {
       $div.not(':last').remove()
    }
    

    But I would prevent duplication at first place.

    edit: Here is another alternative using filter and slice method:

    $('.test.className').filter(function() {
        return this.textContent === 'content';
    }).slice(0, -1).remove();
    

    In the above snippet by using -1 as the second argument of the .slice method, the last element in the set is ignored.

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

Sidebar

Related Questions

So basically I have something like this <div class=iframe-holder> <span></span> <iframe src=iframe.html width=200 height=200
I'm trying to remove contents of particular div which are basically list items and
Below is the code I keep trying; I'm basically just trying to use this
I have some HTML like this: <div id=SomeID> <div class=Wrapper> <input type=checkbox class=SomeCheckboxClass> <input
In this html I basically have a sidebar-div and a page-div with the header,
So basically, I have a div which is runat=server <div id=results runat=server class=results></div> Now,
I'm basically trying to create a 2 column div with a liquid <h1> and
I have page like this: <ul id=cards> <li id=card1> <div>...</div> <div id=panel1> <form>...</form> <ol
I have a rails template form with this code: <div class=field> <%= f.label :title
I've coded the following functions to switch the content for divs using keypresses. Basically

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.