skip to Main Content

I want to select text from html below, I want to select only this text

Adobe Illustrator, Adobe Photoshop

<div class="col-xs-12">
 <h4 class="dl-title">Professional Skills</h4>
 <div class="divider"></div>
Adobe Illustrator, Adobe Photoshop

here is my code

$('.col-xs-12:not(.dl-title)').eq(15).text().trim()

I use eq(15) because in the website that I going to get data from has alot of .col-xs-12.

Please help me! Thanks in advance

3

Answers


  1. Please Use This:

    $('.col-xs-12').children().remove().end().text().trim()
    

    When you need to add any class or .eq(15) then add

    Login or Signup to reply.
  2. Try using $.parseHTML() , .html() , Array.prototype.pop() , .textContent

    var text = $.parseHTML($(".col-xs-12").eq(15).html()).pop().textContent;
    
    var text = $.parseHTML($(".col-xs-12").html()).pop().textContent;
    console.log(text)
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js">
    </script>
    <div class="col-xs-12">
      <h4 class="dl-title">Professional Skills</h4>
      <div class="divider"></div>
      Adobe Illustrator, Adobe Photoshop
      </div>
    Login or Signup to reply.
  3. Try this

     $(".col-xs-12")
            .clone()    //clone the element
            .children() //select all the children
            .remove()   //remove all the children
            .end()  //again go back to selected element
            .text();
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search