Calling Jquery function in separate file?

Calling Jquery function in separate file?

Hi all

I’m sure this is simple but I can’t work it out.

I have an html file that includes jquery and javascript functions file (functions.js) that contains a simple jquery function.


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"

<html xmlns="" xml:lang="en" lang="en">
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
  <meta name="robots" content="noindex, nofollow" />

  <script src="" type="text/javascript"></script>
  <script src="js/functions.js" type="text/javascript"></script>

  <script type="text/javascript" charset="utf-8">






	function Tester(name){

The jquery function works if called from the bottom of the function.js file.

How can I call the function from the html page?

I tried with

<script type="text/javascript" charset="utf-8">

You currently have your Testing function wrapped inside the jQuery DOM ready function which isn’t part of the global scope, simply move it outside the DOM ready function and it will work fine.

Thanks SgtLegend

Do I need the jQuery DOM ready function at all ?

Not at the moment, when you begin writing your jQuery code then you can use the DOM.ready() method.

Sent from my iPhone using Tapatalk