Trigger event on body load complete js/jquery

前端 未结 10 1820
眼角桃花
眼角桃花 2020-12-05 18:36

I want to trigger one event on page load complete using javascript/jquery.

Is there any way to trigger event or call a simple function once page loading fully comple

10条回答
  •  忘掉有多难
    2020-12-05 19:12

    This will call function when the DOM structure is ready

    $(document).ready(function () {
            userCommission();
            //Show commision box
            $('#userroles').change(function(){
               userCommission();
            });
    
            function userCommission() {
               var roles = $('#userroles').val();
               var result = roles.map(function (x) { 
                    return parseInt(x, 10); 
                });
                var i = result.indexOf(6);           
                console.log(i);
                if(i == -1) {
                    console.log('inside');
                    $('.user-commission :input').attr("disabled", true);;
                    $('#user-commission').hide();
                } 
            } });
    

提交回复
热议问题