$(this).parent().attr("")的含义

<html>
<head>
</head>
<body>
<script type="text/javascript" src = "js/jquery.js"></script>
<script type="text/javascript">
$(function(){
    $("#list01 input[type=checkbox]").click(function(){
        $(this).parent().next().toggle();
        console.log($(this).attr("id"));
        //这是打印了点击元素的id
        console.log($(this).parent().attr("id"));
        //这是打印了,点击元素父元素的id
        console.log($(this).parent().next().attr("id"));
        //这是打印了,input元素的父元素dt元素的,相邻的后面的兄弟元素的id;
    });
    $("#list01 dd").hide();
});
</script>
<dl id="list01">
    <dt id = "11">
        <input type="checkbox" id = "111">名
    </dt>
    <dd id = "12">田</dd>
    <dt id = "21">
        <input type="checkbox" id = "211">所属
    </dt>
    <dd id = "22">大学</dd>
    <dt id = "31">
        <input type="checkbox" id = "311">生年月日
    </dt>
    <dd id = "32">1999年3 月3 日</dd>
</dl>
</body>
</html>

缩进相同的,就是兄弟元素,缩进多的是子元素,缩进少的是父元素。
$("a[name=addcolumnMenu]").die().live("click", function () { var itemid, itemname, contentype, sourceid, thumb, itemtype; // if ($("#cl_list_show").val() == "0") { itemid = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-itemid"); itemname = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-itemname"); contentype = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-contenttype"); sourceid = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-sourceid"); thumb = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-thumb"); itemtype = $(this).parent(".fl").parent(".lk").parent(".pic").parent(".borbg").parent(".mod_sclist").attr("data-itemtype"); //} //else { // itemid = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-itemid"); // itemname = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-itemname"); // contentype = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-contentype"); // sourceid = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-sourceid"); // thumb = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-thumb"); // itemtype = $(this).parent(".btn").parent("td").parent("tr").children().eq(0).attr("data-itemtype"); //} //if ($("#column_list_hid_type").val() == 4) { addsourcetoMenu(itemid, thumb, itemname, contentype, sourceid, itemtype); //} })
06-03
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值