I created a countdown using JS. For that i need jQuery so I created requireJs file.
var config = {
paths: {
'countDown': "ABC_CoundDown/js/countDown"
},
shim: {
'countDown': {
deps: ['jquery']
}
}
};
then added jquery in web/js/jquery.js
then in phtml I used
<script type="text/javascript">
require([
'jquery',
'countDown',
'domReady'
], function(
$,
) {
var date = "2019-02-12";
var myDate = new Date(date);
myDate.setDate(myDate.getDate() + 2);
$("#countdown").countdown(myDate, function (event) {
$(this).html(
event.strftime(
'<div class="timer-wrapper"><div class="time">%D</div><span class="text">days</span></div><div class="timer-wrapper"><div class="time">%H</div><span class="text">hrs</span></div><div class="timer-wrapper"><div class="time">%M</div><span class="text">mins</span></div><div class="timer-wrapper"><div class="time">%S</div><span class="text">sec</span></div>'
)
);
});
});
Best Answer
You have a typo in the js code. Remove the
,
after$
infunction($,)