Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/397.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 无法在jquery中获取表单标记?_Javascript_Jquery - Fatal编程技术网

Javascript 无法在jquery中获取表单标记?

Javascript 无法在jquery中获取表单标记?,javascript,jquery,Javascript,Jquery,我有一个如下所示的表格 <form class="card-photo-body single-image lot-photo dropzone clickable dz-clickable dz-started" id="dropzone-11" action="/Lot/SaveUploadFile" method="post" data-image-type="11" data-image="7bdae02e-d98e-473a-b23d-f54502f99387">

我有一个如下所示的表格

  <form class="card-photo-body single-image lot-photo dropzone clickable dz-clickable dz-started" id="dropzone-11" action="/Lot/SaveUploadFile" method="post" data-image-type="11" data-image="7bdae02e-d98e-473a-b23d-f54502f99387">
                                    <input type="hidden" name="listingid" value="98b1a9ef-2888-40b4-8622-cef2a88a2da4">
                                    <input type="hidden" name="type" value="11">
                                    <input type="file" style="display: none;" accept="image/*">
                                    <div class="dz-message" data-dz-message="" style="display: none;">
                                        <svg width="78" height="66">
                                            <title>Image Upload</title>
                                            <desc>Camera</desc>
                                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/content/images/sprite.svg#camera"></use>
                                        </svg>
                                            <div class="card-photo-body-text">
                                                Drag photo here or <strong>upload</strong>
                                            </div>
                                    </div>
                                <div class="preview dz-success dz-complete" data-image="7bdae02e-d98e-473a-b23d-f54502f99387">
                            <div class="dz-image">
                                <img src="" data-dz-thumbnail="">
                                <div class="image" style="">
                                    <img src="/Lot/Image?id=7bdae02e-d98e-473a-b23d-f54502f99387">
                                </div>
                            </div>
                            <div class="progress" style="display: none;">
                                <div class="bar" style="width: 0%;" data-dz-uploadprogress=""></div>
                            </div>
                                <img remove-file="" class="remove" src="/Content/images/close.png">
                        </div></form>
但是我期待上面的html,但是我只得到FormElemnt的内部部分

   <input type="hidden" name="listingid" value="98b1a9ef-2888-40b4-8622-cef2a88a2da4">
                                    <input type="hidden" name="type" value="11">
                                    <input type="file" style="display: none;" accept="image/*">
                                    <div class="dz-message" data-dz-message="" style="display: none;">
                                        <svg width="78" height="66">
                                            <title>Image Upload</title>
                                            <desc>Camera</desc>
                                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/content/images/sprite.svg#camera"></use>
                                        </svg>
                                            <div class="card-photo-body-text">
                                                Drag photo here or <strong>upload</strong>
                                            </div>
                                    </div>
                                <div class="preview dz-success dz-complete" data-image="7bdae02e-d98e-473a-b23d-f54502f99387">
                            <div class="dz-image">
                                <img src="" data-dz-thumbnail="">
                                <div class="image" style="">
                                    <img src="/Lot/Image?id=7bdae02e-d98e-473a-b23d-f54502f99387">
                                </div>
                            </div>
                            <div class="progress" style="display: none;">
                                <div class="bar" style="width: 0%;" data-dz-uploadprogress=""></div>
                            </div>
                                <img remove-file="" class="remove" src="/Content/images/close.png">
                        </div>

图像上传
摄像机
将照片拖到此处或上传

我应该怎么做才能得到整个表单标签,包括?

你想要得到整个html吗?使用
$(event.target).closest('form')[0]
如果只使用
$(event.target).closest('form').html()
,您将获得innerhtml

$(event.target).closest('form').prop('outerHTML')
   <input type="hidden" name="listingid" value="98b1a9ef-2888-40b4-8622-cef2a88a2da4">
                                    <input type="hidden" name="type" value="11">
                                    <input type="file" style="display: none;" accept="image/*">
                                    <div class="dz-message" data-dz-message="" style="display: none;">
                                        <svg width="78" height="66">
                                            <title>Image Upload</title>
                                            <desc>Camera</desc>
                                            <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="/content/images/sprite.svg#camera"></use>
                                        </svg>
                                            <div class="card-photo-body-text">
                                                Drag photo here or <strong>upload</strong>
                                            </div>
                                    </div>
                                <div class="preview dz-success dz-complete" data-image="7bdae02e-d98e-473a-b23d-f54502f99387">
                            <div class="dz-image">
                                <img src="" data-dz-thumbnail="">
                                <div class="image" style="">
                                    <img src="/Lot/Image?id=7bdae02e-d98e-473a-b23d-f54502f99387">
                                </div>
                            </div>
                            <div class="progress" style="display: none;">
                                <div class="bar" style="width: 0%;" data-dz-uploadprogress=""></div>
                            </div>
                                <img remove-file="" class="remove" src="/Content/images/close.png">
                        </div>