更新时间:2023-01-17 18:53:55
( #Panel ul li a)。find( [value ='art6'])。parent()。css( 这里的样式);
i想要访问A的父亲Li,并操纵它!
但它不起作用我怎么能这样做?
plz help!kquote>在jQuery中,find()
方法是
获取当前每个元素的后代一组匹配的元素,由选择器,jQuery对象或元素过滤。
所以问题是你的第一个选择器一直到锚点本身,然后你的find()正在寻找一个锚的后代。
改为这个它会起作用:
(#Panel ul li)。find(a [value ='art6'])。parent()。css(styles here);
i have this code:
$("#Panel ul li a").find("[value='art6']").parent().css("styles here");
i want to access the Li , father of A , and manipulate it!
but it does not work how can i do that?
plz help!("#Panel ul li a").find("[value='art6']").parent().css("styles here");
i want to access the Li , father of A , and manipulate it!
but it does not work how can i do that?
plz help!
In jQuery, thefind()
method is to
"Get the descendants of each element in the current set of matched elements, filtered by a selector, jQuery object, or element."
So the problem is that your first selector goes all the way down to the anchors themselves, then your find() is looking for a descendant of an anchor.
Change to this and it will work:
("#Panel ul li").find("a[value='art6']").parent().css("styles here");