jquery traversing to find a parent's parent

前端 未结 7 701
谎友^
谎友^ 2021-01-14 08:58

HTML:

  • 7条回答
    •  灰色年华
      2021-01-14 09:59

      var p = $('.del').parents('li');
      console.log(p);
      

      http://jsfiddle.net/hZY8R/

      The .parents() and .parent() methods are similar, except that the latter only travels a single level up the DOM tree.

      As you can see, when you use parents with a selector, you will be fine.

    提交回复
  • 热议问题