javascript - jquery组合多个选择器

标签 javascript jquery html

alert($('.input-large[name="name"]:parent:parent').html());

我的 html 是:

<div class="control-group">
    <label for="name" class="control-label">Clinic Name</label>
    <div class="controls">
       <input type="text" name="name" id="name" class="input-large" value="">
    </div>
</div>

我的警报为空。如何找到输入元素的父元素的父元素?

最佳答案

尝试

alert( $('#name').parent().parent().html() );

关于javascript - jquery组合多个选择器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11694467/

相关文章:

javascript - jQuery:我怎样才能绕过使用 if 语句来摆脱 "undefined"错误

javascript - 切换按钮可见性

PHP/Javascript 验证计算

javascript - 即使发生匹配,$.grep 也会返回空数组

javascript - CSS:如果 p 的高度覆盖,则增加父宽度

html - 复选框不检查内部数据组件 =""

javascript - 将文本框动态添加到使用 Mysql Jquery 生成的每一行时出现错误

php - 接收jquery函数发送的php文件数据

jquery - 在大结果上使用 phonegap 自动完成 jQuery

javascript - jquery 选项卡的 onclick 事件