Hide the submit button after clicking

I know that there are many answers on how to hide the submit button after a click, but I cannot find any solution to work. I tried to hide it with onclick=""javascript as well. The form is for the wordpress plugin.

echo '<p><input type="submit" name="submitted" id="send" value="Send"></p>';
+4
source share
3 answers

I would do what @Nexxuz suggested, but to add, if you hide the button in order to prevent duplicate views, you should probably associate the button hiding with the submit event in the form, as this is the "Submit" button, as well as the user. pressing enter

$(document).ready(function($) {
    $('#myForm').on('submit', function(evt) {
        $('#send').hide();
    });
});
+2
source

If you have jQuery, you can do something simple:

$(document).ready(function() {
    $('#send').on('click', function() {
        $(this).hide();
    });
});
+4

You can do this by adding onclick = "this.style.display = 'none';" as shown in the provided code snippet.

echo '<p><input type="submit" name="submitted" id="send" value="Send" onclick="this.style.display='none';"></p>';
0
source

Source: https://habr.com/ru/post/1612570/


All Articles