Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

145
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda