Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

146
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda