Call external jQuery file -
hi trying write web app using jquery , want separate js code html markup. here code:
file: index.html
<!doctype html> <html> <head> <meta charset="utf-8"> <title>customer search</title> <script src="js/jquery-1.9.1.min.js"></script> </head> <body> ... <input type="button" id="button_batch_update" value="save"/> <script type="text/javascript" src="js/customer_search.js"></script> </body> file: customer_search.js
!function($){ $("#button_batch_update").click(function(e){ e.preventdefault(); alert("u clicked me!"); }); }(window.jquery); i copied js file code bootstrap website (http://twitter.github.io/bootstrap/javascript.html). works, don't understand why external js file work. me out this? thanks!
when include external file, including part of current html page.
so, if have external file looks this:
<script> function myfunc(){ } </script> and include in html header, it's if function written in original html document:
<html> <body> <script> function myfunc(){ } </script> </body> </html> therefore allowing call function.
by way ...
while we're having discussion, may inform you can many other types of files including, not limited to:
- css
- php
- xml
- ...
Comments
Post a Comment