1

I want to create a external java script file that should contain some validation functions. I want to add j query into my java script file, how can i do this,

I tried the following code but it seems to be not working,

var script = document.createElement('script');
script.src = 'http://code.jquery.com/jquery-1.11.0.min.js';
script.type = 'text/javascript';
document.getElementsByClassName('email')[0].appendChild(script);
durai
  • 359
  • 1
  • 4
  • 12

1 Answers1

-1

Ideally you should add reference to jQuery in your .html file which is going to refer the external javascript file containing validation functions.

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.4/jquery.min.js"></script>
<script src="<your java script file containing validation functions></script>
Sasi Dhar
  • 1,379
  • 1
  • 9
  • 7