返回值:NumberjQuery.inArray(value, array)
概述
確定第一個參數(shù)在數(shù)組中的位置,從0開始計數(shù)(如果沒有找到則返回 -1 )。
參數(shù)
valueAny
用于在數(shù)組中查找是否存在
arrayArray
待處理數(shù)組。
示例
描述:
查看對應(yīng)元素的位置
jQuery 代碼:
var arr = [ 4, "Pete", 8, "John" ];
jQuery.inArray("John", arr); //3
jQuery.inArray(4, arr); //0
jQuery.inArray("David", arr); //-1