0

次のような HTML を取得しました。

<table>
    <form action=\'food.php\' method=\'POST\'>
    <tr><h4>
        <td><span><input type="submit" name="food_edit" class="food_edit" value="Edytuj" /></span></td>
       </h4>
    </tr>
    </form>
</table>

そして、入力フィールドを変更する jQuery の関数:

wrap.find('.food_edit')
    .replaceWith('<input type=\'submit\' name=\'food_edit_confirm\' value=\'Potwierdź\' />');

私の問題は、送信ボタンを変更した後、送信フォームが機能しないことです。

4

4 に答える 4

0
<script type="text/javascript">
$(function(){
$('.food_edit').replaceWith("<input type='submit' name='food_edit_confirm' value='Potwierdz' onclick='document.getElementById(\"submit\").click();' />");

});
</script>


<form action='food.php' method='POST'>
        <input type="submit" name="food_edit" class="food_edit" value="Edytuj" onclick="document.getElementById('submit').click();" />
        <input type="submit" style="display:none" id="submit" />
    </form>

非表示のボタンは、交換可能な送信ボタンで何かをしても、常にフォームを送信します。

于 2013-07-26T17:20:29.603 に答える
0

送信ボタンを置き換えた後、これを試すことができます:

$('form').on('click','input[type=submit]',function(){
   //rest of code goes here.
});
于 2013-07-26T16:59:07.737 に答える