jquery 数组元素个数
简单JavaScript代码段可删除数组的第一个元素。 您也可以轻松删除数组的最后一个元素。 只需使用JavaScript array.shift()和array.pop()方法即可。 这些方法改变了数组的长度!
var myarray = ["item 1", "item 2", "item 3", "item 4"];
//removes the first element of the array, and returns that element.
alert(myarray.shift());
//alerts "item 1"
//removes the last element of the array, and returns that element.
alert(myarray.pop());
//alerts "item 4"
不要忘记将jQuery代码放在文档就绪函数中。 有关更多信息,请参见4个不同的jQuery文档就绪示例 。
jquery 数组元素个数