Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

144
Views
jQuery: Remove string that has no parent element

I have a document that I can't edit in PHP looking like this:

<div class="car-search-field-div">
  <label class="simple_hide">Türen</label>
     <div class="myClear"></div>

     doors_count

     <input id="car-search-form-field-doors_count" name="search[doors_count]" type="text" value="" placeholder="Anzahl Türen ab">
 </div>

Now I am trying to remove the string "doors_count" via jQuery but can't adress it properly. When I try something like:

$('.car-search-field-div').remove('iventory_number', '');

The placeholder of the input field gets removed, but the string "doors_number" still is there. I also thought of using the xpath of the string, but that doesn't work either.

Is there a way to adress / remove a string that has no element wrapped around it? Thank you very much in advance!

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

you can remove inside all text inside .car-search-field-div

$('.car-search-field-div').contents().filter(function () {
     return this.nodeType === 3; 
}).remove();

more detail enter link description here

demo

about 4 years ago · Juan Pablo Isaza Report

0

You need DOM access

document.querySelector(".car-search-field-div").childNodes.forEach(node => {
  if (node.nodeType === 3 && node.textContent.trim() === "doors_count") node.remove()
})
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<div class="car-search-field-div">
  <label class="simple_hide">Türen</label>
  <div class="myClear"></div>
  doors_count
  <input id="car-search-form-field-doors_count" name="search[doors_count]" type="text" value="" placeholder="Anzahl Türen ab">
</div>

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!