How to negate code in “if” statement block in JavaScript -JQuery like 'if not then..'

后端 未结 2 1701
花落未央
花落未央 2020-12-09 01:49

For example if I want to do something if parent element for used element hasn\'t got ul tag as next element, how can I achieve this?

I t

2条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-12-09 02:08

    Try negation operator ! before $(this):

    if (!$(this).parent().next().is('ul')){
    

提交回复
热议问题