Home > Software engineering >  Get span value inside nested div and other HTML element using jQuery
Get span value inside nested div and other HTML element using jQuery

Time:02-10

I want to get span value which is inside h1> a> span tag so those span value I want to get but when my jQuery code is getting empty values, unable to figure out what I have missed.

$(".main_content .wpb_wrapper").each((i, elem) => {

  console.log('test::'   $(elem).find(".wpb_content_element >a >span").text());
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>


<div >
  1)

  <div >
    <div >
      <h3 style="text-align: center;"><a href="https://abc/"><span style="color: #405789;">abc Estates</span></a></h3>
    </div>
  </div>

</div>

2)

<div >
  <div >
    <div >
      <h3 style="text-align: center;"><a href="https://xyz/"><span style="color: #405789;">xyz Estates</span></a></h3>
    </div>
  </div>
</div>

3)

<div >
  <div >
    <div >
      <h3 style="text-align: center;"><a href="https://mm/"><span style="color: #405789;">mm Estates</span></a></h3>
    </div>
  </div>
</div>
</div>

CodePudding user response:

  •  Tags:  
  • Related