使用jQuery删除不包含值的字段

这是我早先提出的问题。 我有一组通过循环生成的表单字段。

我也有一个链接,点击时调用jQuery函数。 该链接打开一个模式对话框,该对话框也有一个表单。 我想在对话框中提交表单时删除通过循环创建的字段,这些字段不包含任何值。


编辑:

在测试代​​码后,我意识到因为我提交了我的表单,页面实际上得到了刷新,我使用了所有的值。 所以,我需要做相反的事情 – 用值收集所有字段,在我提交表单后,我需要将所有带有值的字段插回页面。 现在我需要以下代码的帮助:

$("#myLink").click(function(){ $("#newForm").dialog({ buttons: { "Submit": function() { $("myForm").submit(); // BELOW is where I need help var fieldWithValue = ""; if($('input[value != ""]').length > 0) { $this = $(this); fieldWithValue += $this.parent(); } $("#vals").html(fieldWithValue); }, "Cancel": function() { $(this).dialog("close"); } } }); }); foreach ($arrays as $listValue) { echo ' 
'; }
link

 if ( $.trim( $( this ).val() ) == '' ) { $( this ).parent().remove() } 
 $('input[value!=""]').val().length == 0 $('input:text[value=""]').parent().remove();