Quantcast
Channel: jQuery By Example
Viewing all 248 articles
Browse latest View live

Direct vs Delegated Events with jQuery on() method

$
0
0
jQuery added a new method called  on()  in release 1.7 which provides all functionality for attaching event handlers. And it has made other event handler event like live() and delegate() dead. This method was introduced due to performance issue with live() method.

Related Post:

There are 2 signaturs of  on()  method.
  1. .on(events[,selector] [,data ],handler(eventObject))
  2. .on(events[,selector] [,data])
In this post, we will focus on the one of the optional parameter named "selector". The official jQuery documentation about this parameter says,

"A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element."

As this is an optional parameter, so it can be omitted. The present/absence of this parameter defines Direct Event or Delegated Event. If it is absent, then it is called "Direct event", otherwise "Delegated event". First, we will see what Direct event means.

For example, there are 2 div element present on the page,
<div>First Div</div><div>Second Div</div>
And attach a click event on div element using on() method, which just alerts the clicked element text.
$(document).ready(function () {
    $('div').on('click', function() {
        alert("Clicked: " + $(this).html());
    });
});
So the above jQuery code instructs "HEY!!!! I want every div to listen to click event. And when you are clicked , give me alert." Now, this is absolutely fine and works like charm. This is called "Direct Event". But there is an issue with Direct events. Official jQuery document about Direct events says,

"Event handlers are bound only to the currently selected elements; they must exist on the page at the time your code makes the call to .on()."

So for Direct events to work, the element has to present on the page. If it is added dynamically, it's not going to work.

Consider the same example, which now on click event adds a div element dynamically, after showing alert. But the click event don't get attached to dynamically added elements.
$(document).ready(function () {
    $('div').on('click', function() {
        alert("Clicked: " + $(this).html());
        $('<div>Dynamic Div</div>').appendTo('body');
    });
});
So when dynamically added div elements are clicked, nothing happens! As the event is not attached to them.
So, what is the solution now? Well, solution is to use "Delegated events". Delegated events have the advantage that they can process events from descendant elements that are added to the document at a later time.

When a selector is provided, the event handler is referred to as delegated. So let's modify the above jQuery code to have "Delegated event" instead of "Direct event".
$(document).ready(function () {
    $(document).on("click","div", function(){
        alert("Clicked: " + $(this).html());
        $('<div>Dynamic Div</div>').appendTo('body');
    });
});
So the jQuery code instructs "HEY!! document when your child element which is div gets clicked, give me alert and append a dynamic div to body." Using delegated event, you will find the same behavior for already present and dynamically added elements.
There is another advantage of using delegated event which is "much lower overhead". For example, On a table with 1,000 rows in its tbody, below code attaches a handler to 1,000 elements.
$("#Table tbody tr").on("click", function(event){
  alert($(this).text());
});
On the other side, using "Delegated event", attaching event handler to only one element which is tbody. The event only needs to bubble up one level (from the clicked tr to tbody).
$("#Table tbody").on("click", "tr", function(event){
  alert($(this).text());
});
Let's take another example, to explain "Delegated events". Consider following Html code.
<div id="container"> <span> Span within Container div. </span><br/> <span> Another span within Container div. </span></div>
And below is jQuery code to attach (delegated) click event on span element within div with ID "container" is,
$(document).ready(function () {
  var iCount = 1;
  $('div#container').on("click", "span", function () {
    alert("Clicked: " + $(this).html());
    var $dynSpan = $('<br/><span> Dynamic Span ' + iCount + '.</span>');
    $dynSpan.appendTo('div#container');
    iCount++;
  });
});
Here is another important tips "Attaching many delegated event handlers near the top of the document tree can degrade performance". For best performance, attach delegated events at a document location as close as possible to the target elements as done in above jQuery code. So instead of $(document).on("click","div#container span", function(){ , use $('div#container').on("click", "span", function () {

Feel free to contact me for any help related to jQuery, I will gladly help you.

What's new in jQuery 2.0

$
0
0
You asked for it, you got it: jQuery 2.0 has arrived! Oh Yes!! jQuery 2.0 is finally released and this version leaves behind the older Internet Explorer 6, 7, and 8 browsers. jQuery 2.0 is intended for the modern web. But don’t worry, the jQuery team still supports the 1.x branch which does run on IE 6/7/8. If you're upgrading from a version before 1.9, we recommend that you use the jQuery Migrate plugin.

Related Post:

Download Links
The final jQuery 2.0.0 files can be found here on the jQuery CDN:

http://code.jquery.com/jquery-2.0.0.min.js (minified, for production)
http://code.jquery.com/jquery-2.0.0.js (unminified, for testing)

The files should also be available on the Google and Microsoft CDNs soon.

What's new in 2.0
  • No more support for IE 6/7/8
  • Reduced size
  • Custom builds for even smaller files
  • jQuery 1.9 API equivalence

There is no major changes that they have made or nothing new has been incorporated. This release comes up with lots of bug fixes.

Feel free to contact me for any help related to jQuery, I will gladly help you.

Show only Month and Year in only one jQuery UI DatePicker in case of Multiple DatePicker

$
0
0
In one of my previous post, I had posted about Show only Month and Year in jQuery UI DatePicker, but there was an issue with the code explained in that particular post. The issue was that it was applicable for all the datepickers present on the page and it is quite possible to have such behavior for one datepicker and rest of the datepickers control should work their default functionality.


Related Post:

How to do it?


To implement this, follow below steps only for that control for which you want to show Month and Year appear as Dropdown.
  • Set changeMonth and changeYear to true.
  • Set date format to "MM yy".
  • jQuery DatePicker has "onClose" event, which is called when Datepicker gets closed. So using this event, fetch the selected Month and Year and setDate of Datepicker.
  • jQuery DatePicker also has "beforeShow" event, which is called before the datepicker is displayed. So this event will be used to Show the previously selected Month and Year as selected. If you don't use this event, then datepicker will always show the current month and current year, irrespective of your previous selection.
  • Now, here is tricky part. Use focus() and blur() event of the textbox control to hide default behavior of the datepicker. And in focus() event, set the position of "ui-datepicker-div" which is created by datepicker control itself and this holds UI for having month and year dropdown.
$(document).ready(function () {
   $('#txtDate').datepicker({
    changeMonth: true,
    changeYear: true,
    dateFormat: 'MM yy',

    onClose: function () {
      var iMonth = $("#ui-datepicker-div .ui-datepicker-month :selected").val();

      var iYear = $("#ui-datepicker-div .ui-datepicker-year :selected").val();

      $(this).datepicker('setDate', new Date(iYear, iMonth, 1));
      $(this).datepicker('refresh');
    },

    beforeShow: function () {
      if ((selDate = $(this).val()).length > 0) 
      {
        iYear = selDate.substring(selDate.length - 4, selDate.length);

        iMonth = jQuery.inArray(selDate.substring(0, selDate.length - 5), $(this).datepicker('option', 'monthNames'));

        $(this).datepicker('option', 'defaultDate', new Date(iYear, iMonth, 1));
        $(this).datepicker('setDate', new Date(iYear, iMonth, 1));
      }
    }
  });

   $("#txtDate").focus(function () {
      $(".ui-datepicker-calendar").hide();
      $("#ui-datepicker-div").position({
          my: "center top",
          at: "center bottom",
          of: $(this)
      });
   });

   $("#txtDate").blur(function () {
     $(".ui-datepicker-calendar").hide();
   });
});
See result below
See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

Split an image into strips using jQuery

$
0
0
In this post, find out about a jQuery plugin that gives your images a bit of WOW! Yes, this jQuery plugins allows to split the image into any number of strips.

PicStrips adds a little style to your images to help them stand out from the crowd. You can split your images into any number of strips, specify the white space between each strip and also the amount of vertical white space added at the top and bottom of alternate strips.


Related Post:

How to use it?


It's very easy to use. All you need to do is to make call to picstrips method on your image which you want to split into strips.
$("#imgStrip").picstrips({
    splits: 7,
    hgutter: '10px',
    vgutter: '20px',
    bgcolor: '#fff'
});

Options


This plugin currently supports 4 different options (as specified in above sample code).
  • splits - The number of strips you want to split the image into.
  • hgutter - The horizontal gutter between each strip.
  • vgutter - The vertical gutter overlayed at the top and bottom of alternate strips.
  • bgcolor - The background colour of the vertical overlays (defaults to white).
Official Website
Feel free to contact me for any help related to jQuery, I will gladly help you.

Remove related videos from YouTube videos using jQuery

$
0
0
You must have notice that YouTube shows related videos link at the end of playback. This is sometimes quite annoying when you have embedded a video specific to your website and other related videos come up. So in this post, find jQuery code to remove related video shown at the end of playback.


Related Post:

To remove related video, all you need to do is to append "rel=0" to YouTube video URL.
$(document).ready(function () {
    $('iframe[src*="youtube.com"]').each(function () {
        var sVideoURL = $(this).attr('src');
        if (sVideoURL.indexOf('rel=0') == -1) {
            $(this).attr('src', sVideoURL + '?rel=0');
        }
    });
});
See result below


See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

jQuery library file size over the years

$
0
0
The first version of jQuery library was released on August 26, 2006 and after that there was no looking back. In last 6 years, jQuery has come a long way and now we have jQuery 2.0, which was released recently. Yesterday, I was going through the history of jQuery and realized how jQuery has steadily kept increasing in size. But this is natural as new functionality is added and lot of effort goes to make it better.

But, it was interesting enough for me to find out how much the file size has increased since its release. So, I went ahead and put this is in form of charts. And guess what, find an interesting thing. If you see the graph, you will find the size is keep on increasing with every release but the recent version 2.0 size is decreased. This is probably due to no support for IE :)

I have only include the major version, not the minor version while creating these graphs.
If you want to find out size of every single release starting with jQuery 1.2, then visit here.

Feel free to contact me for any help related to jQuery, I will gladly help you.

Highlight first day of every month in jQuery UI Datepicker

$
0
0
With continuation of jQuery UI Datepicker series articles, here is another post which gives solution to highlight very first day of each month in jQuery UI Datepicker control.

First, define a CSS class to show highlighted effect.
.firstDay a{
   background-color : #00FF00 !important;
   background-image :none !important;
   color: #000 !important;
}
And use "beforeShowDay" event provided with jQuery UI Datepicker control which gets called before building the control. This event can be used to assign specific class to specific dates.
$(document).ready(function () {
    $("#txtDate").datepicker({
        beforeShowDay: function (date) {
            return [true, date.getDate() == 1 ? "firstDay" : ""];
        }
    });
});
See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

Change the Page Mood based on Time of Day using jQuery

$
0
0
The post title "Change the Web Page Mood based on time of Day using jQuery" is quite interesting!!! Isn't it? Yes, you can very easily do it now with jQuery. Based on time, you can change the back-color, font-color of your webpage so that it provides a good user experience. For example, a white background in afternoon is perfect and if the same page is viewed in night then black background will make things pretty.

Related Post:

jQuery Plugin "Aware.js" will allow you to do exactly the same. Aware.js is a simple jQuery plugin that allows a site to customize and personalize the display of content based on a reader's behavior without requiring login, authentication, or any server-side processing.

See Demo below. All you need to do is to change the time using slider and see how it works.



Along with this feature, the plugin also allows to drastically alter the layout an otherwise static page in three different ways based on the reader's personalized relationship with the content.
Feel free to contact me for any help related to jQuery, I will gladly help you.

Free jQuery Courses and Training material

$
0
0
In this post, we bring you a list of Free jQuery Course and Training Material which are useful from beginner to an expert. Of course, this blog has some useful, handy material but the below list has some serious and exceptional training materials which are created specifically for training purpose.

  • Try jQuery. Try jQuery walks you through the most fundamental building blocks of jQuery, from actually getting the library into your page to selecting, manipulating, and creating DOM elements, and reacting to user input.
  • Learn jQuery is the official learning portal for the library. If you're looking for explanations of the basics, workarounds for common problems, best practices, and how-tos, then that's the right place!
  • jQuery Fundamentals is designed to get you comfortable working through common problems you'll be called upon to solve using jQuery.
  • Lessons by appendTo() has collection of free video lessons on JavaScript, jQuery, events, methods and selectors.
  • Learn jQuery in 30 Days is a free newsletter course by tutsplus. Once you subscribe, each day you'll be sent a free video lesson in your email for 30 days.
  • jQuery Succinctly was written to express, in short-order, the concepts essential to intermediate and advanced jQuery development. Its purpose is to instill in you, the reader, practices that jQuery developers take as common knowledge.
Feel free to contact me for any help related to jQuery, I will gladly help you.

jQuery : Execute/Run multiple Ajax request simultaneously

$
0
0
Yesterday for one of my requirement, I needed to execute/run multiple ajax request simultaneously or in parallel. Instead of waiting for first ajax request to complete and then issue the second request is time consuming. The better approach to speed up things would be to execute multiple ajax request simultaneously.


Related Post:

To do this, we can use jQuery .when(). The $.when() provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events.

To show how it works, will send multiple ajax request to Flickr API to fetch some photos. The first request will fetch photos which are tagged with "moon" and the second request will fetch photos tagged with "bird". And then we display the results in a div of both the requests.

The basic syntax is,
$.when(request1, request2, request3.....)
So here is 2 ajax request to flickr API. To iterate through the response, there is a callback function attached to it. This callback function gets executed once both the ajax request are finished.

In the case where multiple Deferred objects are passed to $.when(), it takes the response returned by both calls, and constructs a new promise object. The res1 and res2 arguments of the callback are arrays, where res1 has response of first request and res2 has response from second request.
$(document).ready(function () {
   $.when($.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", {
        tags: "moon",
        tagmode: "any",
        format: "json"
   }),
   $.getJSON("http://api.flickr.com/services/feeds/photos_public.gne?jsoncallback=?", {
        tags: "bird",
        tagmode: "any",
        format: "json"
   })).then(function (res1, res2) {
       $.each(res1[0].items, function (i, item) {
          var img = $("<img/>");
          img.attr('width', '200px');
          img.attr('height', '150px');
          img.attr("src", item.media.m).appendTo("#dvImages");
          if (i == 3) return false;
      })
      $.each(res2[0].items, function (i, item) {
          var img = $("<img/>");
          img.attr('width', '200px');
          img.attr('height', '150px');
          img.attr("src", item.media.m).appendTo("#dvImages");
          if (i == 3) return false;
      })
  });
});
See Complete Code
You can also declare what to do in case of success and failure of ajax request. Below jQuery code execute the function myFunc when both ajax requests are successful, or myFailure if either one has an error.
$.when($.ajax("/page1.php"), $.ajax("/page2.php"))
  .then(myFunc, myFailure);
Read more about $.when.

Feel free to contact me for any help related to jQuery, I will gladly help you.

How to make multiple select dropdown list using jQuery

$
0
0
In this post, find a jQuery plugin called "Multiple Select" which allows to make/create/convert a simple dropdown list to multiple select/multi-select dropdown. "Multiple Select" is a jQuery plugin to select multiple elements with checkboxes :).

Related Post:

Options:
  • Default option allows to show checkbox.
  • Ability to grouping elements
  • Features to show multiple items in single row
  • Select All options
  • Feature to show placeholder

Browser Compatibility:
  • IE 7+
  • Chrome 8+
  • Firefox 10+
  • Safari 3+
  • Opera 10.6+
This plugin also provides events to disable and enable the dropdown element.
Feel free to contact me for any help related to jQuery, I will gladly help you.

Scroll Page Automatically by few pixels after every few seconds using jQuery

$
0
0
It would be nice feature for web pages if the web page scrolls automatically by few pixels after every 2, 3 or 5 seconds so that the users don't have to scroll it. This is quite useful for webpages having articles, posts, very long text or lengthy pages.

So, In this post you will find jQuery way to "Scroll Page Automatically by few pixels after every few seconds".

Related Post:

For the demo purpose, we will be scrolling the webpage by 200 pixels and after every 2 seconds. To do this, we need to use JavaScript "setInterval" method, which is responsible for calling a function/particular code after x seconds. So in this case, it would be 2 seconds.

Then, all you want is to get window scrollTop value and add 200 to it and then just scroll it.. Simple and Easy!!!!!
$(document).ready(function () {
    setInterval(function () {
        var iScroll = $(window).scrollTop();
        iScroll = iScroll + 200;
        $('html, body').animate({
            scrollTop: iScroll
        }, 1000);
    }, 2000);
});
Now, there is an issue which above approach. That is, once you reach at the bottom of the page you setInterval will keep on calling the function after every 2 seconds which is not desired. One way is to disable the automatic scrolling once user reaches at bottom of the page.

To do this, check if user has reached to bottom of the page and then call "clearInterval()" to stop setInterval.
$(document).ready(function () {
    var myInterval = false;
     myInterval = setInterval(function () {
        var iScroll = $(window).scrollTop();
        if (iScroll + $(window).height() == $(document).height()) {
            clearInterval(myInterval);
        } else {
            iScroll = iScroll + 200;
            $('html, body').animate({
                scrollTop: iScroll
            }, 1000);
        }
    }, 2000);
});
If the above solution don't work, then please make sure that you have include document type at top of the page.
<!DOCTYPE HTML>
The issue with above approach is that it gets executed only once. As once user reaches at bottom of the page, then setInterval is stopped. What if you want to have it again once user reaches at top of the page? Below jQuery code block exactly does the same thing.

As once bottom of the page is reached, then setInterval is stopped. So need to find a way to enable it again. And that can be done in $(window).scroll event. In this event, check if user has reached at top of the page. If yes, then reset setInterval.. That's it..

Note: For demo, I have set 500 as pixels to scroll.
$(document).ready(function () {
    var myInterval = false;
    myInterval = setInterval(AutoScroll, 2000);

    function AutoScroll() {
        var iScroll = $(window).scrollTop();
        iScroll = iScroll + 500;
        $('html, body').animate({
            scrollTop: iScroll
        }, 1000);
    }
    
    $(window).scroll(function () {
        var iScroll = $(window).scrollTop();
        if (iScroll == 0) {
            myInterval = setInterval(AutoScroll, 2000);
        }
        if (iScroll + $(window).height() == $(document).height()) {
            clearInterval(myInterval);
        }
    });
});
If the above solution don't work, then please make sure that you have include document type at top of the page.
<!DOCTYPE HTML>
Feel free to contact me for any help related to jQuery, I will gladly help you.

6 Best jQuery Vertical & Horizontal News Ticker Plugins

$
0
0
News ticker are one of the most popular ones of them in web design. It is a useful, tiny and handy feature as it can be used to display news, notification, tweets, recent/ popular posts or articles and many more things. Below you will find 6 best jQuery Vertical & Horizontal News Ticker Plugins that are perfect to implemented in your sites.

Related Post:

1. jQuery News Ticker


Taking inspiration from the BBC News website ticker, jQuery News Ticker brings a lightweight and easy to use news ticker to jQuery.



2. Totem


Totem is a jQuery plugin that lets you create an animated vertical ticker. Totem makes vertical tickers easy to implement by turning a list of items into an animated ticker that auto-advances and specifying anchors for stop, start, next, and previous navigation links.


3. Modern News Ticker [Paid]


Modern News Ticker is a modern, powerful, flexible, fast, easy to use and customize news ticker. It offers a varied number of features while still being lightweight and very easy to work. It comes with 4 different effects, 4 different layouts and 15 different themes.


4. jQuery – Easy ticker Plugin


jQuery easy ticker is a news ticker like plugin, which scrolls the list infinitely. It is highly customizable with lot of features and it is cross browser supported.


5. liScroll


liScroll is a jQuery plugin that transforms any given unordered list into a scrolling News Ticker



6. vTicker


vTicker is easily added to your existing web page by including jQuery, the vTicker plug-in javascript file and then by simply calling the vTicker plug-in with the selector(s) you wish to create a vTicker with.


Feel free to contact me for any help related to jQuery, I will gladly help you.

Cool jQuery Plugins released in May 2013

$
0
0
Today we bring a list of latest jQuery plugins released in May 2013. These plugins are fresh, interesting, simple and lightweight. You may find them useful for your next project!!!

Related Post:

jQuery Swatches


This is a jQuery plugin that turns a single div into a sweet color swatch.


Magnific-Popup


Magnific Popup is a free responsive jQuery lightbox plugin that is focused on performance and providing best experience for user with any device.


Least.js


least.js is a Random & Responsive HTML 5, CSS3 Gallery with LazyLoad.


Waterfall


Waterfall is a powerful and customizable jQuery plugin for creating dynamic and responsive Pinterest like layout which supports infinite ajax scroll.


TimeTo


timeTo is an easy-to-use and customizable jQuery plugin for creating countdown timers or digital clocks with a lot of options and callback support.



FlipClock


FlipClock.js is a jQuery plugin with CSS3 animations to add counter, timer and clock with smooth flip effect.



Zerobox


Lightweight, animated lightbox plugin for Jquery JavaScript library.



Multiple Select


Multiple select is a jQuery plugin to select multiple elements with checkboxes :).


Feel free to contact me for any help related to jQuery, I will gladly help you.

jQuery .end() and Chaining

$
0
0
Before you go further, I assume that you know What is chaining in context of jQuery? If not, then first read "What is Chaining in jQuery?". To summarize Chaining in jQuery means to connect multiple functions, events on selectors. Main advantage of using chaining is that it makes code look clean and gives better performance. You should make a habit of using chaining.

Related Post:

You will find that chaining is very easy to implement and indeed it is. But consider a scenario, where in a <div> element, find all <p> and <span> elements and assign background color to them. Below jQuery code will exactly do the needful.
$(document).ready(function () {
   $('div').find('p').css("background", "yellow");
   $('div').find('span').css("background", "pink");
});
Can this be done using chaining? The first line of code $('div').find('p'), will select all the <p> tag element in <div> and change background color. Since using find() we have filtered out all <p> elements so we need to use selector again to select <span>tag element and we can't use chaining. Fortunately, jQuery has .end() function which end the most recent filtering operation in the current chain and return to its previous state. Like,
$(document).ready(function () {
    $('div')
       .find('p').css("background", "yellow")
       .end()
       .find('span').css("background", "pink");
});
This chain searches for <p> tag element in <div> and turns their backgrounds yellow. Then .end() returns the object to its previous state which was before the call to find(), so the second find() looks for <span> inside <div>, not inside <p>, and turns the matching elements' backgrounds to pink. The .end() method is useful primarily when exploiting jQuery's chaining properties.
See Complete Code
Feel free to contact me for any help related to jQuery, I will gladly help you.

10 Free jQuery Plugin for Shopping Cart and E-Commerce website

$
0
0
Find below a complied list of 10 free jQuery shopping cart plugin and tutorial that are suitable for e-commerce website. These plugins can be used for showing Product images, for image zoom, 360 degree display of product, integrate with Shopping Cart for payment, showing list of stores and for many other features.

Related Post:

Smart Cart


Smart Cart is a flexible and feature rich jQuery plug-in for shopping cart. It makes the add-to-cart section of online shopping much easy and user friendly. It is compact in design, very easy to implement and only minimal HTML required.


jQuery Store Locator


This jQuery plugin takes advantage of Google Maps API version 3 to create an easy to implement store locator. No back-end programming is required, you just need to feed it KML, XML, or JSON data with all the location information.


jPayPalCart jQuery Plugin


jPayPalCart is a simple to integrate JQuery plugin that allows you to create a fully functioning Paypal shopping cart without using clunky server-side page refreshes. The plugin supports PayPal Website Payment Standard.


Multi-Item Slider


jQuery plugin for creating category slider, best for eCommerce websites.


Credit Card Validator


jQuery Credit Card Validator detects and validates credit card numbers. It’ll tell you the detected credit card type and whether the number length and Luhn checksum are valid for the type of card.


j360


j360 is a jQuery plugin designed to display 360 view of product using a set of images.


Ajax Paypal Cart JQuery Plugin


AJAX PayPal Cart is a easy to use JQuery plugin for web developer to add a full function shopping cart in their website. The AJAX cart can included a cart widget which allow display of cart information easily. Support PayPal Website Payment Standard.


jQZoom


JQZoom is a javascript image magnifier built at the top of the popular jQuery javascript framework. jQzoom is a great and a really easy to use script to magnify what you want.


LightBox 2


Lightbox is a simple, unobtrusive script used to overlay images on top of the current page. It's a snap to setup and works on all modern browsers. It present images in a slick window, while darkening the rest of the page. It can be used to show various images of single product.


productColorizer


productColorizer is a light-weight solution for users to quickly preview a product in different colors


Feel free to contact me for any help related to jQuery, I will gladly help you.

Get Client IP address using jQuery

$
0
0
In this post, find jQuery code to get Client's IP address. There are 2 free online services which allows you to get Client IP address.

1. jsonip.com
: is a free utility service that returns a client's IP address in a JSON object with support for JSONP, CORS, and direct requests. It serves millions of requests each day for websites, servers, mobile devices and more from all around the world.

All you need to do is to make a call to jsonip.com.
$(document).ready(function () {
    $.get('http://jsonip.com', function (res) {
        $('p').html('IP Address is: ' + res.ip);
    });
});

2. Smart-IP.net
: Smart IP for today is one of the leading services providing to it's users all the required information about IP-addresses and everything related to them.
$(document).ready(function () {
    $.getJSON('http://smart-ip.net/geoip-json?callback=?', function(data) {
        $('p').html('My IP Address is: ' + data.host);
    });
});
Along with the IP address, this service also provide Geo location details as well like Country, latitude, longitude etc. Following are the properties which are returned as JSON response by this service.
data.host;
data.countryName;
data.countryCode;
data.city;
data.region;
data.latitude;
data.longitude;
data.timezone;
Feel free to contact me for any help related to jQuery, I will gladly help you.

5 Free jQuery Image Map Marker Plugins

$
0
0
Here is a complied list of 5 Free jQuery image map marker plugins which are quite handy if you wish to highlight or make your maps interactive using marker. Not only maps, with these plugins you can mark any picture to make it interactive with descriptions.

Related Post:

ImageMapster


ImageMapster is a jQuery plugin that lets you activate HTML image maps without using Flash. It works just about everywhere that JavaScript does, including modern browsers, Internet Explorer 6, and mobile devices like iPads, iPhones and Androids.


jQuery Map Marker Plugin


This plugin makes it easy to put multiple markers on Map using Google Map API V3. Map Marker is very useful when you have a list of data & you want to show all of them on Map too.


iPicture


iPicture is a jQuery Plugin to create interactive pictures with extra descriptions.


Maphilight


Maphilight is a jQuery plugin that adds visual hilights to image maps.


qTip


qTip is an advanced tooltip plugin for the ever popular jQuery JavaScript framework.


Feel free to contact me for any help related to jQuery, I will gladly help you.

jQuery Plugins For Language Translation

$
0
0
Find list of jQuery plugins which can be integrated in your website for language translation. These are useful if you are building a multilingual website which offers many language to end user. You can also use this plugins as Translator as well. Enjoy!!!

Related Post:

jTextTranslate



Lingua Localization



jQuery-lang-js


This jQuery plugin allows you to create multiple language versions of your content by supplying phrase translations from a default language such as English to other languages.


jQuery.tr


jQuery.tr is a jQuery plugin which enables you to translate text on the client side. You can get or set the dictionary the plugin uses by calling $.tr.dictionary. It is a object made by key-value pairs, with the original sentence or string id as key, and the translated sentence as value.

Feel free to contact me for any help related to jQuery, I will gladly help you.

Check for '#' hash in URL using jQuery

$
0
0
In this short post, find jQuery code to check if URL contains "#" (hash) or not. This can be checked via location.hash property provided by JavaScript and same can be used in jQuery.
$(document).ready(function(){
    if(window.location.hash) {
      // # exists in URL
    } 
    else {
       // No # in URL.
    }
});
Feel free to contact me for any help related to jQuery, I will gladly help you.
Viewing all 248 articles
Browse latest View live