要判断数组中是否包含某个元素,从原理来来说,就是遍历整个数组,然后判断是否相等,
var arr = [ "xml", "html", "css", "js" ];
$.inArray("js", arr); //返回 3,
如果不包含在数组中,则返回 -1;
以上就是本文的全部内容了,有需要的小伙伴参考下吧
Statement:The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn