简体   繁体   中英

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.

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. */
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM