Reputation: 9898
I want to do a simple animation clicking on this link
<a id="C" href="http://www.google.com">Make me disappear</a>
Callback is
$("#C").click(function(event) {
event.preventDefault();
$(this).hide("slow");
});
while on jfiddle my code works, I am not able to make run this callback on a jsp page. I wrote js code in a different file imported with
<script type="text/javascript" src="scripts/lib.js"></script>
I am quite sure jQuery and lib.js are being included because from developer tools console (on Chromium) I can make it do the animation; moreover they are both in developer tools' scripts tabs.
Thanks
Upvotes: 0
Views: 1754
Reputation: 539
Notice that on jfiddle it's including your jQuery click handler in the page's onload
function; are you doing that in your lib.js file?
$(function() {
$("#C").click(function(event) {
event.preventDefault();
$(this).hide("slow");
});
});
(Using $(function() {});
is a shorthand for running that code when the DOM is ready - see the jQuery .ready() documentation.)
Or even better:
(function($) {
// do your stuff here
})(jQuery);
to be able to handle possible future conflicts.
Upvotes: 7