“Remova o texto e mantenha a div dentro de um div jQuery 2” Respostas de código

Remova o texto e mantenha a div dentro de um div jQuery 2

$(function() {
  $("#to-clean, #to-clean *")                  // selects the element and all element nodes inside it
    .contents()                                // selects all child nodes including tags, comments and text
    .filter(function() {
      return this.nodeType === Node.TEXT_NODE; // filter text nodes
    }).remove();                               // boom!
});
Selim Soufargi

Remova o texto e mantenha a div dentro de um div jQuery 2

$(function() {
  $("#to-clean, #to-clean *")                  // selects the element and all element nodes inside it
    .contents()                                // selects all child nodes including tags, comments and text
    .filter(function() {
      return this.nodeType === Node.TEXT_NODE; // filter text nodes
    }).remove();                               // boom!
});
Selim Soufargi

Respostas semelhantes a “Remova o texto e mantenha a div dentro de um div jQuery 2”

Perguntas semelhantes a “Remova o texto e mantenha a div dentro de um div jQuery 2”

Procure respostas de código populares por idioma

Procurar outros idiomas de código