user2961861
user2961861

Reputation:

trouble linking .js file and jquery to html page

I trying to reproduce a hardcopy version of a jsfiddle I made:

http://jsfiddle.net/bsapaka/5fv9B/25/

I am having trouble getting the javascript to work. My HTML head has the following:

<script src="jquery-2.0.3.min.js"></script>

<script src="my-tabs.js"></script>

"my-tabs.js" contains the javascript from the jsfiddle. Both files are in the same directory as the HTML file.

Upvotes: 0

Views: 43

Answers (1)

codefactor
codefactor

Reputation: 1646

Your fiddle has the javascript executed onLoad - but your html has the script inside the head - which is where the difference lies.

Wrap all the code in your my-tabs.js with a

$(function() {
   /* your code here. */
});

Upvotes: 2

Related Questions