Select :first-child or :last-child that doesn't contain some specific class

前端 未结 3 820
一个人的身影
一个人的身影 2021-01-21 22:35

Assume we\'re having a list with 5 items and we want to apply some specific styles to the first or the last child. But the functionality of this list will requi

3条回答
  •  耶瑟儿~
    2021-01-21 22:45

    Do you mean something like this?

    var notHidden = $('div').not('.hide');
    notHidden.first().css('color', 'red');
    notHidden.last().css('color', 'red');
    

提交回复
热议问题