开发者

dynamic tag count on keyup

开发者 https://www.devze.com 2022-12-29 20:17 出处:网络
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

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 k开发者_如何学Goeyup event occurs?

Thanks, rodchar


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

That should do it, substitute values as needed.


jquery size() Returns the number of matched elements.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消