子元素知道时如何获取jQuery中的父元素? [英] How to get parent element in jQuery when child element is known?

查看:110
本文介绍了子元素知道时如何获取jQuery中的父元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用jQuery Mobile,为您创建了大量的DOM。我需要删除()单选按钮,但是基于HTML在jQuery Mobile中的构造方式,我没有父div的id。我可以很容易地抓住输入和标签,但也需要摆脱我们的div,从单选按钮列表中完全删除条目样式。

 < div class =ui-radio> 
< input type =radiovalue =ahBkMjid =ahBkMjname =spamdata-theme =c>
< label for =ahBkMjclass =ui-btn ui-btn-icon-left ui-btn-up-c>
< span class =ui-btn-inner>
< span class =ui-btn-text> Foo< / span>
< span class =ui-icon ui-icon-ui-icon-radio-off ui-icon-radio-off>< / span>
< / span>
< / label>
< / div>


解决方案

将jQuery的 .parent() do?


I'm using jQuery Mobile which creates a lot of the DOM for you. I need to remove() radio buttons, but based on how the HTML is constructed in jQuery Mobile, I do not have an id for the parent div. I can easily grab both the input and labels, but need to also get rid of the our div to completely removed the entry styling from the list of radio buttons.

<div class="ui-radio">
  <input type="radio" value="ahBkMj" id="ahBkMj" name="spam" data-theme="c">
  <label for="ahBkMj" class="ui-btn ui-btn-icon-left ui-btn-up-c">
    <span class="ui-btn-inner">
      <span class="ui-btn-text">Foo</span>
      <span class="ui-icon ui-icon-ui-icon-radio-off ui-icon-radio-off"></span>
    </span>
  </label>
</div>

解决方案

Will jQuery's .parent() do ?

这篇关于子元素知道时如何获取jQuery中的父元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆