获取jQuery对象的第一个子元素
2021-04-30 23:30
标签:strong ul li art pre back class child span 元素 注意:.get()得到DOM对象,而.eq()、.first()、.children()、.find()等得到jQuery对象 原文链接:https://blog.csdn.net/PrisonersDilemma/article/details/90259555 获取jQuery对象的第一个子元素 标签:strong ul li art pre back class child span 元素 原文地址:https://www.cnblogs.com/firstcsharp/p/12148710.html ul>
li>1li>
li>2li>
li>3li>
ul>
script>
console.log($(‘ul li:first‘));
console.log($("ul>li:first"));
console.log($(‘ul‘).children(‘li‘).get(0));
console.log($(‘ul‘).children(‘li‘).eq(0));
console.log($(‘ul‘).children(‘li‘).first());
console.log($(‘ul‘).find(‘li‘).get(0));
console.log($(‘ul‘).find(‘li‘).eq(0));
console.log($(‘ul‘).find(‘li‘).first());
console.log($(‘ul‘).children(‘:first‘));
console.log($(‘ul‘).children(‘li:first‘));
console.log($(‘ul‘).children(‘li:first-child‘));
console.log($(‘ul‘).children(‘li:nth-child(1)‘));
console.log($(‘ul‘).find(‘:first‘));
console.log($(‘ul‘).find(‘li:first‘));
console.log($(‘ul‘).find(‘li:first-child‘));
console.log($(‘ul‘).find(‘li:nth-child(1)‘));
script>