jQuery获取元素的父亲 [英] jquery get father of element
本文介绍了jQuery获取元素的父亲的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个位于div内的元素.我想通过孩子的ID来获取div,这可能吗?如果可以,怎么办?
I've got an element which resides inside a div. I'd like to get the div by the child's ID, is this possible? if so how?
谢谢!
推荐答案
尝试一下:
$("#id").parent()
我的第一个建议#id:parent
无效,因为 :parent
选择了所有节点是其他节点(包括文本节点)的父节点.
My first suggestion #id:parent
doesn’t work as :parent
selects all nodes that are parent of other nodes (including text nodes).
这篇关于jQuery获取元素的父亲的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文