jquery 数组元素个数_jQuery删除第一个数组元素

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文档就绪示例

翻译自: https://www.sitepoint.com/jquery-remove-array-element/

jquery 数组元素个数

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值