引用jquery中选择器内的表单

leo*_*ora 0 jquery jquery-selectors

如果我在jquery中有这个代码:

var parentDiv = $(this).parent('.copyInstance');
Run Code Online (Sandbox Code Playgroud)

在这个div里面有一个表格.

我如何引用此选择器中的表单元素?我想要这样的东西

  $.post($(parentDiv + " Form").attr('action'), $(parentDiv + " Form").serialize(),  function(data) {
    });
Run Code Online (Sandbox Code Playgroud)

但上面这似乎不起作用

ale*_*teg 6

要引用children元素,可以使用.find(),例如:

$.post(parentDiv.find('form').attr('action'), 
       parentDiv.find('form').serialize(),
    function(data) {
    });
Run Code Online (Sandbox Code Playgroud)

根据它的结构,您也可以使用.children(),如:

parentDiv.children('form')
Run Code Online (Sandbox Code Playgroud)