In my HTML,
<script src="jquery-2.1.3.min.js"></script>
<script type='text/javascript' src='editor-script.js'></script>
I had put the jquery-2.1.3.min.js
in the same folder as jQuery but whenever I run code in jQuery the HTML acts like the code isn't there.
$.ready(function(){
$("#file-tab").click(function(){
$("#file-tab").append('<div id="tab-file"></div>');
});
});
What i'm trying to run on jQuery^ (it's file name is editor-script.js
). file-tab
is a div
id in the HTML file.
Your ready
event is incorrect.
The recommended way is:
$(document).ready(...);
Or this: (though not recommended by jQuery)
$().ready(...);
Or:
$(function() { ... });
I just did an alert in the jQuery file and it worked. That means it's properly linked up to the file. I changed the code to $(document).ready(...)
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.