trigger method in jQuery

We can execute events by using jQuery's trigger method. With trigger method we can execute one event at a time. trigger method execute events synchronously. trigger method takes argument as event type string (i.e. click). Example is mentioned below: trigger() method example


<html>
<head>
    <title>Example</title>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
</head>
<body>

    <form id="sourceform">
        <p>Source Content</p>
    
    <br>
    <button id="btnReplace">Replace example</button>
    </form>

    <script> 
        $(document).ready(function () {
            $('#btnReplace').on('click', function () {
                $("#sourceform").trigger("submit");
            });
        });
    </script>
</body>
</html>