Selecting first div usin jquery [closed]

陌路散爱 提交于 2020-05-30 03:17:09

问题


How we can select first div of page using jquery ?


回答1:


jQuery first select: http://api.jquery.com/first-selector/

The :first pseudo-class is equivalent to :eq(0). It could also be written as :lt(1). While this matches only a single element, :first-child can match more than one: One for each parent.

Sample:

var div = $('div:first');

Fiddler example: http://jsfiddle.net/wBQfm/




回答2:


Get the first using this:

var first_div = $( $('div')[0] );


来源:https://stackoverflow.com/questions/13316869/selecting-first-div-usin-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!