简体   繁体   中英

Automatically Submit Button click()

Hi I have to submit a form immediatly when the page is loaded because when the form is submitted, I get the name of the JSNode tree to search and make it in evidence.

This is my script:

$(window).load(function() {
            $("#s").submit(function(e) {
            e.preventDefault();
            $("#albero").jstree(true).search($("#q").val());
            });
        });


echo "<form id=\"s\"><input type=\"hidden\" id=\"q\" value=\"$username\"/><button type=\"submit\" id=\"submit\">Invia</button>
             </form>";

But the problem is that when the page is totally loaded it doesn't happen anything.

you can use trigger() trigger Jquery same as :

$("#s").submit(function(e) {
   e.preventDefault();
   $("#albero").jstree(true).search($("#q").val());
}).trigger('submit');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM