jquery - Hide <li> nested inside two divs -


i have following html, , want target hiding first 2 <li> instances. struggling addressing <li> inside list, have multiple other lists of same class on page, want target 1 only.

as such, looking able nest jquery statement targetting <li> inside <ul class="productlist"> inside <div class="blockcontent"> inside <div class="featured">

<div class="featured" id="#featured">    <div class="blockcontent">       <ul class="productlist">          <li>product here</li>       <--- hide          <li>product here</li>       <--- hide            <li>product here</li>          <li>product here</li>       </ul>    </div> </div> 

this current attempt:

$('.featured').find('ul:li(2)').hide(); 

how can modify hide first 2 <li> elements?

jquery's slice() function allow target specific range of elements given selector. instance hide first 2 <li>s in example, want do:

$('#featured .blockcontent ul.productlist li').slice(0, 1).hide() 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -