How to get value by class name in JavaScript or jQuery?

javascript, jquery

Solution

If you get the the text inside the element use

Text()

$(".element-classname").text();

In your code:

$('.HOEnZb').text();

if you want get all the data including html Tags use:

html()

 $(".element-classname").html();

In your code:

$('.HOEnZb').html();

Hope it helps:)

Problem

I wan to retrive all the value of this code using class name. Is it possible in jQuery? I want to retrive only the text within a div or number of div may be change the next form. ``` <span class="HOEnZb adL"> <font color="#888888"> </br> <div> <i><font color="#3d85c6" style="background-color:#EEE"></i> </div> <div> **ZERONEBYTE Software** | <a target="_blank" href="http://www.example.com"> **www.zeronebyte.com** </a> <a target="_blank" href="mailto:info@example.com"> **info@zeronebyte.com** </a> </br> </div> <div> <div> <div> **+91-9166769666** | <a target="_blank" href="**mailto:deepika.zeronebyte@example.com**"></a> </div> </div> </div> </font> </span> ```

Original source