Noob Noob - 1 year ago 83
Javascript Question

Reading values from label in Jquery

I have many label and each of them has same class.My Label contains some information, which I need to read. How to read label attributes in Jquery. So far I could get object using $ but unable to get any value from its property.I need to get values for Id,Text, and title. Please help me to get those values .

$(".tagLabel").each(function (i, obj) {

var lableId = ?? // what I need to do with obj here to get it
var labelText=??
var lableTitle=??


Answer Source

Please try this:

$(".tagLabel").each(function (i, obj) {
    var lableId =;
    var labelText= $(obj).text();
    var lableTitle= $(obj).attr('title');


Please note that you have to wait until your page is fully loaded, wrap your code with:

$(function() {
    //Page fully loaded
    //Put you code here
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download