jQuery - Access elements in array

前端 未结 3 1254
借酒劲吻你
借酒劲吻你 2021-01-05 07:24

I need to be able to get the width of elements from an array

HTML

  • --------
相关标签:
3条回答
  • 2021-01-05 07:49

    You can also do something like this using nth-child:

    $("#container li:nth-child(1)").width(); // first li
    
    0 讨论(0)
  • 2021-01-05 07:52

    You can use .eq function like below,

    $array.eq(2).width()
    

    DEMO: http://jsfiddle.net/8zvkn/2/

    $array[2] - returns DOM element but what you need is the jQuery object which has the .width function.

    0 讨论(0)
  • 2021-01-05 07:59

    Use eq :

    $('#container li').eq(i)
    
    0 讨论(0)
提交回复
热议问题