Abdallah
Abdallah

Reputation: 543

Get the text from a div with a certain condition

I have a big div containing many divs inside, I need to get the text from those inner divs but at certain condition, something like this:

for (var i = 0; i < g; i++)
        {
            var h = $('#infor > div').["dataid = i"].text();
            alert(h);
        }

(infor) is the id for the big div and (dataid) is the attribute of the inner divs

Upvotes: 1

Views: 130

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

You need to use:

 var h = $('#infor > div[dataid = '+ i +']').text();

Upvotes: 3

Related Questions