不能改变同位素过滤从结束到开始

can't change isotope filtering from end with on start with

isotope 的主页上存在按名称过滤以结尾的演示,但我需要按名称开始过滤,这对于按字母过滤非常有用。请帮助我,我是 javascript.

的菜鸟

这个演示:

$container.isotope({ filter: function() {
  var name = $(this).find('.name').text();
  return name.match( /ium$/ );
} })

"ends with" 部分来自您使用的正则表达式。末尾的“$”是字符串结尾字符,确保仅当在您的姓名字符串末尾找到该字符串时正则表达式才匹配。

对于开始于,尝试类似的东西:

return name.match( /^ium/ );

“^”与“$”相反,它匹配字符串的开头