如题所述
第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>本回答被提问者采纳
<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()