tags:

views:

28

answers:

3
+1  A: 

The extra parenthesis aren't needed around $('.layer'+count).text() but it should work nevertheless. Are you absolutely sure you selector matches the element? You can test that by using alert($('.layer'+count).length), that would alert the amount of elements matched.

Tatu Ulmanen
+1  A: 

What happens when you do:

alert($('.layer'+count).text())
Paul Manzotti
It gets my text if any or it gets no text
Mircea
+1  A: 
if ( ($('.layer'+count).text().length ) > 0 )
{
    alert ('I have text')
}

In your code the paranthesis order was not the right one. It should be

($('.layer'+count).text().length)

and not

($('.layer'+count).text()).length

Actually there is no need of the extra (. You can simply write

if ( $('.layer'+count).text().length > 0 )
{
    alert ('I have text')
}
rahul
I just tried it out in firebug and it works fine with the surrounding parentheses
David Archer
It looks that it works if I do the following: if ( $('.layer'+count).text().length > 1 )For every letter in the text the $('.layer'+count).text().length the value is incremented by 1.So it works.Thanx for the solution!
Mircea