父元素选择问题?

Sta*_*arx 1 javascript jquery jquery-selectors

我的HTML是这样的

<div id="mydiv" class="common">
      <input type="text" id="text1" value="" />
      <input type="text" id="text2" value="" />
</div>
Run Code Online (Sandbox Code Playgroud)

我正在像这样在文本框的onclick事件上分配一个函数

$(document).ready(function() {
      $(".common input").click(function() {

          //////// What I am trying to do is access the id of its parent 
                // in this case it is "mydiv"
          alert($(this:parent).attr('id'));
});
Run Code Online (Sandbox Code Playgroud)

但它没有用

Kee*_*per 6

尝试 $(this).parent().attr('id');