FROM node:10 WORKDIR /usr/src/app COPY package*.json ./ RUN npm install pm2 -g RUN npm install COPY . . EXPOSE 8080 CMD [“pm2-runtime”, “server.js”]
Leave a CommentCategory: Javascript / JQuery Snippets
Let us see an example of how to calculate the difference between dates using Javascript. First, write an HTML code with Javascript as below: const…
Leave a CommentArray.ForEach is about 95% slower than for() in for each for Arrays in JavaScript. So, don’t use: var data = []; arr.forEach(function (item) { data.push(item);…
Leave a CommentHere is the simple JavaScript code snippet to check if the given number is an odd or even number. Function to check Number Is Odd…
Leave a CommentjQuery make it easy to preload images in the background so visitors won’t have to wait forever when they would like to display an image.…
Leave a Comment$(‘.btn’).hover(function(){ $(this).addClass(‘hover’); }, function(){ $(this).removeClass(‘hover’); } );
Leave a CommentOccasionally we have times when we have broken image links on our website and replacing them one by one isn’t easy, so adding this simple…
Leave a Commentvar sometext = “here is more HTML”; $(“p#text1”).append(sometext); // added after $(“p#text1”).prepend(sometext); // added before
Leave a Commentvar maxheight = 0; $(“div.col”).each(function(){ if($(this).height() > maxheight) { maxheight = $(this).height(); } }); $(“div.col”).height(maxheight);
Leave a Comment$(“a[href=’#top’]”).click(function() { $(“html, body”).animate({ scrollTop: 0 }, “slow”); return false; });
Leave a Comment$(“a”).on(“click”, function(e){ e.preventDefault(); });
Leave a Commentif ($(‘#myElement’).length > 0) { // it exists }
Leave a Commentif($(‘#myDiv’).is(‘:empty’)) { // do something }
Leave a Comment$(‘#element’).hover( function(){ $(this).addClass(‘hover’) }, function(){ $(this).removeClass(‘hover’) } )
Leave a CommentWebFontConfig = { google: { families: [ ‘PT+Sans:400,400italic:latin’, ‘Ubuntu:300,400,500:latin’ ] } }; var cb = function() { var wf = document.createElement(‘script’); wf.src = ‘//ajax.googleapis.com/ajax/libs/webfont/1/webfont.js’; wf.type…
Leave a Comment