Javascript does not load function

Asked

Viewed 96 times

0

I have a javascript file 'zip code'. where there is a method called displays(); but when I run this method in my current file that is on the page next to HTML, it doesn’t work, why?

cep.js

$ (document).ready(function () {
     function exibe()
     {
          alert ('Hello');
     }
  });

index.html

HTML
.
.
.

@section ('page-script')
<script src = "{{asset ('js/cep.js')}}"> </ script>
   $ (document).ready(function () {                    
             exibe();    
   });

</ script>
@endsection

1 answer

1


Because you have declared your function within another, and not in the global scope. Do so:

cep.js

function exibe()
{
     alert ('Hello');
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.