在数组中查找字符串作为mootools中的值

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了在数组中查找字符串作为mootools中的值相关的知识,希望对你有一定的参考价值。

You can find a string as an array row value.
Ex:
arr=['abcde','mdleo']
arr.find('dbd') -> array['abcde']
arr.find('akdowewo') -> array[] (empty)
  1. // NEEDS MOOTOOLS 1.2 FRAMEWORK
  2.  
  3. Array.prototype.find = function(searchStr) {
  4. var returnArray = [];
  5. this.each(function(objeto,index){
  6. if (objeto.contains(searchStr)) {
  7. returnArray.push(objeto);
  8. alert('hay uno');
  9. }
  10. });
  11. return returnArray;
  12. }

以上是关于在数组中查找字符串作为mootools中的值的主要内容,如果未能解决你的问题,请参考以下文章