获取div的父ID

时间:2012-11-05 21:12:36

标签: jquery html

我在这里发现很多文章都在谈论寻找父母的身份和身份。我尝试了所有这些,但没有成功。

这是我的代码:

<html>
<head>
<title>a</title>
<link rel="stylesheet" href="http://code.jquery.com/ui/1.9.0/themes/base/jquery-    ui.css" />
<script src="http://code.jquery.com/jquery-1.8.2.js"></script>
<script src="http://code.jquery.com/ui/1.9.0/jquery-ui.js"></script>
<script type="text/javascript" src="http://www.appelsiini.net/download/jquery.jeditable.js"></script>
<script type="text/javascript">
$(document).ready(function() {
$('.edit_area').editable('edit.php', { 
submitdata : {pid : $(this).parents('div:eq(0)').attr('id')},
//submitdata : {pid : $(this).closest("div").attr("id")},
//submitdata : {pid : $(this).parent().attr('id')},
//submitdata : {pid : this.parentNode.id},
//submitdata : {pid : $(this).parent().get(0).id},
//submitdata : {pid : $(this).parent()[0].id},

type      : 'textarea',
cancel    : 'Cancel',
submit    : 'OK',
//indicator : '<img src="img/indicator.gif">',
tooltip   : 'Click to edit...'
});
});
</script>
</head>
<body>
<div id="b112233">
<div class="edit_area" id="k123">hi</div>
</div>
</body>
</html>
谢谢。

1 个答案:

答案 0 :(得分:2)

使用函数创建额外参数:

submitdata : function() {
       return {pid:$(this).parent('div').attr('id')};
   }
相关问题