问题
I'm trying to set-up flipclock.js on my site however it doesn't seem to be loading no matter what I do, chrome gives me the following error:
Uncaught TypeError: Cannot call method 'FlipClock' of null
My code is laid out as follows:
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script src="/flipclock/src/flipclock/js/libs/base.js"></script>
<script src="/flipclock/compiled/flipclock.min.js"></script>
</head>
<body>
<div class="clock" style="margin:2em;"></div>
<script type="text/javascript">
jQuery(document).ready(function() {
var clock = $('.clock').FlipClock(new Date(2014,8,30).getTime()/1000 - new Date().getTime()/1000, {
clockFace: 'DailyCounter',
countdown: true
});
});
</script>
</body>
All of the jquery files are loading just fine. I only receive that one error mentioned above. I've also tried moving the flipclock files below my body so they load after but with no luck and same error. Would appreciate some ideas on fixing this. Thanks.
回答1:
Try to use:
jQuery('.clock')
instead of:
$('.clock')
来源:https://stackoverflow.com/questions/22400090/flipclock-js-shooting-error-uncaught-typeerror-cannot-call-method-flipclock-o