Anubhav
Anubhav

Reputation: 79

jquery size() for chat box

i am building a chat room using php/mysql and jquery. I need to make sure that only 10 messages are shown at any time. For this i need to know number of divs of chat messages in my chatroom. I have tried using jquery size and length but none seems to work. Please help!

for size m writing: $(#chat).size();

Upvotes: 1

Views: 185

Answers (1)

Neil
Neil

Reputation: 3231

$('#chat') will return a single div that has the id 'chat'. I presume your DIVs do not all have the same ID, since IDs have to be unique. I suspect you have a class instead (class='chat').

In this case you should get the number of such DIVs by:

$('.chat').size();

I'm also assuming you missed out the apostrophes around "#chat" by mistake.

Upvotes: 1

Related Questions