Jquery next not finding the next div?

后端 未结 2 1348
北海茫月
北海茫月 2021-01-18 08:24

I have this HTML structure

Chocolate      
  

        
相关标签:
2条回答
  • 2021-01-18 08:37

    next() only returns the next element in the DOM if it matches the selector, otherwise it returns and empty object. So the only thing you could search for using next() is the <label>. Use this instead:

    $('.cake_checkboxes:first').nextAll('.quantity').first()
    

    jQuery Docs: nextAll()

    0 讨论(0)
  • 2021-01-18 08:49

    siblings also work here

    $('.cake_checkboxes:first').siblings('.quantity')
    
    0 讨论(0)
提交回复
热议问题