How to hide all li except first two in one list, and third and fourth in another?

Viewed 1701

could you please tell me how to hide all li expect first two li ? in secnd case I want to hide all li expect show 3 and 4 li on buttn click here is my code

https://jsbin.com/damolibule/edit?html,js,output

$(function() {
  $('#id_show12').click(function() {
    $('.show12').not(":nth-child(2)").css("display", "none"); 
  })

  $('#id_show34').click(function() {
    $('.show34').not(":nth-child(5)").css("display", "none");  
  })
})

Expected output: when first button click it shows 1 and 2 only. If user clicks on second button it show 3 and 4.

2 Answers
Related