如何使用jquery获取父值 [英] how to get parent value using jquery

查看:106
本文介绍了如何使用jquery获取父值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,



请帮我看看如何从以下代码中获取价值....

 <   ul  >  
< li >
< div >
< input type = chechkbox value = Level1 / >
< / div >
< ul >
< li >
< div >
< input 类型 = chechkbox value = Level1 / >
< / div >
< / li >
< li >
< div >
< input type = chechkbox value = Level1 / >
< / div >
< / li >
< / ul >
< / li >
< / ul >







如何获取父级ul li复选框如果检查子li,则返回值

解决方案

即使您可以使用 id 标记任何元素,并且可以通过 id 值,它可能是一个特别的方法。您需要的是HTML DOM查询。直接使用DOM并通过DOM修改HTML的一种好方法是使用jQuery。请参阅:

http://api.jquery.com/parent/ [ ^ ],

http://api.jquery.com/category/traversing/ [ ^ ]。



参见: http://api.jquery.com/category/manipulation/ [ ^ ]。



如果您需要学习jQuery(强烈推荐),请参阅:

http://en.wikipedia.org/wiki/JQuery [ ^ ],

http://jquery.com [ ^ ],

http://learn.jquery.com [ ^ ],

http://learn.jquery.com/using-jquery-core [ ^ ],

http://learn.jquery.com/about-jquery/how-jquery-works [ ^ ](从这里开始)。



请记住,jQuery在设计时考虑了兼容性。



-SA


 

( 输入[检查检查=])。亲本()


hi all,

Please help me to how to get value from below code....

<ul>
  <li>
     <div>
     <input type="chechkbox" value="Level1"/>
     </div>
     <ul>
         <li>
           <div>
             <input type="chechkbox" value="Level1"/>
           </div>
         </li>
<li>
           <div>
             <input type="chechkbox" value="Level1"/>
           </div>
         </li>
     </ul>
  </li>
</ul>




How to get parent ul li checkbox value if children li is checked

解决方案

Even though you can mark any element with id and that find it by the id value, it could be too much of ad-hoc approach. What you need is the HTML DOM inquiry. One good way to work with DOM directly and also modify HTML via DOM would be using jQuery. Please see:
http://api.jquery.com/parent/[^],
http://api.jquery.com/category/traversing/[^].

See also: http://api.jquery.com/category/manipulation/[^].

If you need to learn jQuery (highly recommended), please see:
http://en.wikipedia.org/wiki/JQuery[^],
http://jquery.com[^],
http://learn.jquery.com[^],
http://learn.jquery.com/using-jquery-core[^],
http://learn.jquery.com/about-jquery/how-jquery-works[^] (start from here).

Remember that jQuery is designed with compatibility in mind.

—SA



("input[checked=checked]").parent()


这篇关于如何使用jquery获取父值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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