Latest news
Home » jQuery

jQuery

Jquery code for Animated Scroll to Top

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 top photo, scroll to top ...

Read More »

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 an error .ajaxSend(): This global ...

Read More »

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){ if(result== “Y”) { alert(‘Your session ...

Read More »

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 click google.maps.event.addListener(infowindow, 'domready', function(){ $('#btn-test').click(function(e) ...

Read More »

Get URL parameters using javascript or jquery

Example URL http://smarttips.in?newsletter=1 <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; })(window.location.search.substr(1).split(‘&’)); $(document).ready(function(){ if(queryString[“newsletter”]==1) { alert(‘Got it!!!’) } }); </script>

Read More »

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 });

Read More »

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') });

Read More »

How To Install Node.js Framework with Express and socket.io 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 : socket.io ,express,http..etc var socket = require( ‘socket.io’ ); var express = require( ‘express’ ); var http = require( ‘http’ ); ...

Read More »

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);       },       afterCopy:function(){         ...

Read More »