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

250
Views
How to clear text only not others element clear by jquery?

$(document).ready(function(){
   $(".final-step").text(" ");
});
 <div class="final-step">i will be remove only <span class="">i will not remove</span> <i class="">me too</i></div>
i try this but it remove all element

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

0

Try This May Be This Will Help You

$(document).ready(function(){
   var f = $(".final-step").html();
   var h = $(".final-step").contents().first();
   var g = f.replace(h.text(), "");
   $(".final-step").html(g)
});
<div class="final-step">i will be remove only <span class="">i will not remove</span> <i class="">me too</i></div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>

about 4 years ago · Juan Pablo Isaza Report

0

Here is a solution on a pure JS

const element = document.getElementsByClassName("final-step")[0]
let childNodes = element.childNodes
for (let node of childNodes){
    if (node.nodeName == '#text'){
        document.getElementsByClassName("final-step")[0].removeChild(node)
    }
}
about 4 years ago · Juan Pablo Isaza Report

0

Here is a solution in JQuery. Is it what you needed?

$(document).ready(function(){
var text = $('.final-step span').text();
   $(".final-step").text(text);
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="final-step">i will be remove only <span class="">i will not remove</span> <i class="">me too</i></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!