如何通过JavaScript或jquery中的类名获取值? [英] How to get value by class name in JavaScript or jquery?
本文介绍了如何通过JavaScript或jquery中的类名获取值?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<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.zeronebyte.com">
**www.zeronebyte.com**
</a>
<a target="_blank" href="mailto:info@zeronebyte.com">
**info@zeronebyte.com**
</a>
</br>
</div>
<div>
<div>
<div>
**+91-9166769666** |
<a target="_blank" href="**mailto:deepika.zeronebyte@gmail.com**"></a>
</div>
</div>
</div>
</font>
</span>
解决方案
如果获得元素内部的文字,请使用
$(".element-classname").text();
在您的代码中:
$('.HOEnZb').text();
如果要获取包括html标记在内的所有数据,请使用:
$(".element-classname").html();
在您的代码中:
$('.HOEnZb').html();
希望它会有所帮助:)
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.zeronebyte.com">
**www.zeronebyte.com**
</a>
<a target="_blank" href="mailto:info@zeronebyte.com">
**info@zeronebyte.com**
</a>
</br>
</div>
<div>
<div>
<div>
**+91-9166769666** |
<a target="_blank" href="**mailto:deepika.zeronebyte@gmail.com**"></a>
</div>
</div>
</div>
</font>
</span>
解决方案
If you get the the text inside the element use
$(".element-classname").text();
In your code:
$('.HOEnZb').text();
if you want get all the data including html Tags use:
$(".element-classname").html();
In your code:
$('.HOEnZb').html();
Hope it helps:)
这篇关于如何通过JavaScript或jquery中的类名获取值?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文