jQuery Tips Everyone Should Know

A collection of simple tips to help you  In   jQuery . Back to Top Button By using the animate and scrollTop methods in jQuery you don’t need a plugin to create a simple scroll-to-top animation: $(‘a.top’).click(function (e) { e.preventDefault(); $(document.body).animate({scrollTop: 0}, 800); }); <!– Create an anchor tag –> <a class=”top” href=”#”>Back to top</a>… Continue reading jQuery Tips Everyone Should Know

Scrolling to the Top and Bottom with jQuery

Here’s a way to scroll to the top or bottom of your website with a simple click. $(function() { // the element which we want to scroll var $elem = $(‘#Mybutton’); // show the buttons $(‘#Go_up’).fadeIn(‘slow’); $(‘#Go_down’).fadeIn(‘slow’); // whenever we scroll fade out both buttons $(window).bind(‘scrollstart’, function(){ $(‘#Go_up,#Go_down’).stop().animate({‘opacity’:’0.2′}); }); // and whenever we stop scrolling… Continue reading Scrolling to the Top and Bottom with jQuery

How to Set and get Cookie Value using Javascript

function SetCookie(c_name, c_value, nDays) {     //deleteCookie(c_name);     var today = new Date();     var expire = new Date();     if (nDays == null || nDays == 0) nDays = 1;     expire.setTime(today.getTime() + 3600000 * 24 * nDays);     var c_value = escape(c_value) + “; path=/” + ((expire == null) ? “” : “; expires=” + expire.toUTCString());     document.cookie = c_name + “=” + c_value;     //document.cookie = c_name + “=” + escape(c_value) + “;expires=” + expire.toGMTString(); } function getCookie(c_name) {     var c_value = document.cookie;     var c_start = c_value.indexOf(” ” + c_name + “=”);     if (c_start == -1) {         c_start = c_value.indexOf(c_name + “=”);     }     if (c_start == -1) {         c_value = null;     }     else {         c_start = c_value.indexOf(“=”, c_start) + 1;         var c_end = c_value.indexOf(“;”, c_start);         if (c_end == -1) {             c_end = c_value.length;         }         c_value = unescape(c_value.substring(c_start, c_end));     }     if (c_value != null && c_value != ‘%’)         return decodeURIComponent(c_value);     else         return c_value; }