Rod
Rod

Reputation: 15457

dynamic tag count on keyup

I have a div that contains many spans and each of those spans contains a single href.

Basically it's a tag cloud. I have a textbox with a keyup event that filters the tag cloud div (It actually just hides the tags if not in filter condition).

Is there a way to get a count of the tags shown as the keyup event occurs?

Thanks, rodchar

Upvotes: 0

Views: 159

Answers (2)

SQueek
SQueek

Reputation: 617

jquery size() Returns the number of matched elements.

$('.tags span a.visible').size();

Upvotes: 2

Zack
Zack

Reputation: 2284

$("#filter_input").keyup( function() {
    count = $("#cloud span:visible").size();
    // Do something with the counted spans.
});

That should do it, substitute values as needed.

Upvotes: 2

Related Questions