使用jquery怎么获取父元素

如题所述

第1个回答  2017-11-09
<!doctype html>
<html>
<head>
<script type="text/javascript"src="

<script>
$(function(){
    var obj = "";
    $("div.class2").click(function(){
        obj = $(this).parent();
        alert(obj.attr("class"));
    });
});
</script>
<style>

div{padding:10px 20px;border:4px solid #ebcbbe;}
div.class1{width:200px;height:120px;}
</style>
</head>
<body>
<div>
    class1
    <div>
        class2
    </div>
</div>

</body>

本回答被提问者采纳
第2个回答  2017-11-08
$(ele).parent()方法
第3个回答  2017-11-08
$("#dom").parent()
第4个回答  2017-11-08
$(this).parent().children()

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网