使用jQuery .each()的动态限制的字符计数器

这个问题是使用类的jQuery字符计数器的扩展? 。

我想在我的textarea字段中添加一个data-content="####" ,然后使用jQuery提取数值并将其应用于字符计数器限制器。

 $("[data-counter-limit]").each(function() { var $this = $(this), limit = +$(this).data("counter-limit"); $this.counter({ goal: limit }); }); 

selector [data-counter-limit]将获得具有属性data-counter-limit所有元素。 剩下的就是解析限制并应用处理元素。

Interesting Posts