Load javascript file after button click

后端 未结 2 424
挽巷
挽巷 2021-01-14 05:56

I am trying to use a set of textboxes to define some data within my JavaScript file. So in a textbox I enter a Team name \"Team name\", and the javascript file uses this tex

相关标签:
2条回答
  • 2021-01-14 06:25

    When you pass a function as the parameter to jQuery it will execute that function during document.ready(). It allows your page to load all of the scripts before executing them.

    $(function() {
        $('#buttontest').click(function() {
            $('div.bracket').show();
            $('div.teamList').hide();
        });
    
        $('#singleElim8').bracket({
            init: singleElim8Data
        })
      $('.bracket').hide();
    });
    
    0 讨论(0)
  • 2021-01-14 06:44

    Just use the getScript method of jQuery

    It's very easy to use

    $( '#buttontest' ).on( 'click', function() {
        $.getScript( 'url to your js file', function( data, textStatus, jqxhr ) {
            // do some stuff after script is loaded
        } );
    } );
    
    0 讨论(0)
提交回复
热议问题