Category: jQuery

Animated Scroll to Top

Jquery code for Animated Scroll to Top

Create a div with class name gotop and Simply Copy paste the jquery code in betweenfor getting a scroll top functionality in a webpage. <div class=’gotop’>Scroll To Top</div> Jquery Code jQuery(window).scroll(function(){ if(jQuery(this).scrollTop()>1){jQuery(‘.gotop’).css({bottom:”0px”})}else{jQuery(‘.gotop’).css({bottom:”-100px”})}});$(window).ready(function(){$(‘.gotop’).click(function(e){e.preventDefault();$(‘html,body’).animate({scrollTop:0},700).animate({scrollTop:60},300).animate({scrollTop:0},400)})})(jQuery); Searches related to Scroll to Top scroll to top jquery, javascript scroll to top, scroll to top bottom of the photos, scroll to

Global Ajax Event Handlers

These following Global Ajax Events to be called at the time of initialization ,completion,success,send..etc. These type of events are triggered on each Ajax request, if the global property in jQuery.ajaxSetup() is true . ajaxComplete():This global event to be triggered when Ajax requests complete. .ajaxError(): This global event to be triggered when Ajax requests complete with

How to Check Expired Sessions using jQuery Ajax and PHP

We can achieve using the php and ajax.The following ajax call execute in every 10 seconds to check the status of session.If it expired the user redirected to seesionout page. Ajax call in every 10 seconds   var check_current_session; function CheckForCurrentSession() { var strSession=”check_current_session=true”; jQuery.ajax({ type: “GET”, url: “check_current_session.php”, data: strSession, cache: false, success: function(result){

How to get a click event inside of google maps infowindow

Jquery events foroogle maps infowindow elements are not work inside $(document).ready(function(){}) or script> tag because the elements not added to the dom when browser execute the jQuery. Solution for this problem is need to add one click listener for google maps infowindow. google.maps.event.addListener(infowindow, ‘domready’, function(e){ //Put your jQuery code here }); //example of infowindow jquery

Get URL parameters using javascript or jquery

Example URL <script> var queryString = (function(url) { if (url == “”) return {}; var smart = {}; for (var i = 0; i < url.length; ++i) { var pS=url[i].split(‘=’, 2); if (pS.length == 1) smart[pS[0]] = “”; else smart[pS[0]] = decodeURIComponent(pS[1].replace(/+/g, “””)); } return pS; })(‘&’)); $(document).ready(function(){ if(queryString[“newsletter”]==1) { alert(‘Got it!!!’) } }); </script>

avoid select2 search box

Comaparatively select2 is faster than select box.Select2  is an alternative of select box with search option. We can avoid this select2 search box by adding the following script:   jQuery(“#dd-from,#mm-from,#yy-from,#dd-to,#mm-to,#yy-to,#time-from,#time-to”). select2({ minimumResultsForSearch :  -1 });

jQuery get($.get) or post( $.post) error catching

In jQuery generally using two methods for data posting. There is a chance of happening errors, for tracking get or post error use a jQuery fail() method. If error occurred will return to jQuery fail() method. $.post(“url”,function(userdata){ alert(userdata) ); }).fail(function(){ // error code here alert(‘page not found’) });

How To Install Node.js Framework with Express and modules

1. Get a repository or package  of node.js using following command sudo apt-get install nodejs 2. After that we need a  NodeJS package manager (npm) sudo apt-get install npm Run the node.js using the command node node.js node.js supports different modules Examples : ,express,http..etc var socket = require( ‘’ ); var express = require( ‘express’ ); var

copy to clipboard using jQuery

<a href=”javascript:void(0);” id=”userlinkId” style=”display: inline;”>http://localhost/profile/sijo</a> <script type=”text/javascript”> jQuery(document).ready(function(){   jQuery(“a#userlinkId”).zclip({       path:’js/ZeroClipboard.swf’,       copy:jQuery(‘#userlinkId’).text(),       beforeCopy:function(){           jQuery(‘#userlinkId’).hide();           jQuery(‘#copymessage’).css(‘color’,’red’);           jQuery(‘#copymessage’).html(‘Copied to clipboard’);           jQuery(‘#copymessage’).delay(2000).fadeOut(400);       },