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>
Try this:
$(document).ready(function(){
var yourArray = [];
$("span.HOEnZb").find("div").each(function(){
if(($.trim($(this).text()).length>0)){
yourArray.push($(this).text());
}
});
});
Without jQuery:
textContent:
var text = document.querySelector('.someClassname').textContent;
Markup:
var text = document.querySelector('.someClassname').innerHTML;
Markup including the matched element:
var text = document.querySelector('.someClassname').outerHTML;
though outerHTML may not be supported by all browsers of interest and document.querySelector requires IE 8 or higher.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.