Traverse up until some element

試著忘記壹切 提交于 2019-12-05 04:16:42

The .closest() method should work (http://api.jquery.com/closest/):

elements.closest("div.vote");

If I understand it correctly you want to traverse to div.votes from div.my_element Try this:

var elements = $('.my_element'); 
var element = elements.closest("div.vote"); 

If you're attempting to find the container element for your current object I suggest the parents() method. It takes a selector, or without one, returns all of the parents of the element.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!