Archive for the ‘Jquery’ Category


Courtesy:-http://designshack.net/articles/javascript/40-awesome-jquery-plugins-you-need-to-check-out/

The jQuery developer community has to be one of the most generous and hardworking group of people on the web. They’re constantly churning out amazingly useful and completely free tools that they share with anyone and everyone who wants to use them.

The quantity and quality of free jQuery plugins simply never ceases to amaze me. I’ve been keeping a list of some great ones that I’ve found lately and I thought I’d share it with you. Here are 40 awesome and free jQuery plugins that just about every web developer should check out.

 

Scrolling

jQuery Waypoints

Waypoints allows you to easily trigger JavaScript events at specific scroll points. Ever wonder how people build those amazing scrolling effects? This could be your answer.

screenshot

skrollr

Parallax scrolling for the masses. Skrollr helps you with all kinds of different scrolling effects including transforms, color shifts and more.

screenshot

Charts, Animations & Tables

Handsontable

A minimalistic approach to an Excel-like table editor in HTML & jQuery. The result is quite impressive, you should definitely give it a shot if you’re looking to build an interactive spreadsheet.

screenshot

jQuery Sparklines

jQuery Sparklines helps you build little inline charts that are supplied with information via HTML or JavaScript.

screenshot

Teamwork Gantt

Build incredible Gantt charts with jQuery. Seriously impressive for a free tool.

screenshot

DataTables

A jQuery plugin for creating impressive, highly functional data tables. Multi-column sorting with data type detection, smart handling of column widths and more.

screenshot

arbor.js

Build crazy looking, futuristic, animated and modular graphs. Really cool stuff.

screenshot

Layout

Wookmark jQuery Plugin

Easily build a Msonry-like layout like the one seen on Wookmark. We featured this on Design Shack here.

screenshot

jQuery Masonry

The original jQuery Masonry. Masonry arranges elements vertically, positioning each element in the next open spot in the grid.

screenshot

Isotope

An amazing layout plugin that allows for intelligent and dynamic grids of items that can be easily sorted and filtered.

screenshot

FitVids.JS

A lightweight, easy-to-use jQuery plugin for fluid width video embeds.

screenshot

gridster.js

Gridster is a really amazing plugin that allows you to create flexible grid layouts that can be rearranged via drag and drop. You should definitely try this one.

screenshot

Freetile.js

Another plugin for masonry-style layout. It allows for any size of elements to be packed without using a fixed-size column grid, so you don’t have to worry about specifying a column width appropriate to the size of your elements.

screenshot

Text

jQuery TextExt Plugin

TextExt is a plugin for jQuery designed to provide functionality such as tag input and autocomplete. According to the developer, it was built on two main values: modularity and extensibility.

screenshot

Jeditable

Jeditable allows you to set certain HTML elements to be editable by the user. You can even set up different types of events to trigger editing capabilities: hover, click, double click, etc.

screenshot

FitText

A plugin for inflating web type. It actually makes it possible to have text that resizes with the viewport. Extremely useful for responsive web design.

screenshot

Cool UI

jQuery Knob demo

This plugin allows you to create really cool circular knobs that spin or fill up as you scroll.

screenshot

noty – A jQuery Notification Plugin

Noty is a jQuery plugin that makes it easy to create alert, success, error, warning, information and confirmation messages as an alternative the standard alert dialog. Each notification is added to a queue.

screenshot

PageSlide

This plugin helps you build a hidden, slide-in sidebar that contains pretty much anything you want it to.

screenshot

jQuery Collapse

“This plugin provides you an accessible and lightweight solution to a widely adopted interface pattern known as progressive disclosure.” That’s fancy-speak for a plugin that allows you to make content collapsable.

screenshot

Avgrund

Awesome and simple modal boxes with a really cool page animation effect.

screenshot

jQuery One Page Navigation

Smooth scrolling navigation and animation for single page sites. Super simple, incredibly handy.

screenshot

jqPagination

A great little pagination plugin. Instead of displaying a list of page numbers like traditional pagination methods, jqPagination uses an interactive ‘Page 1 of 5′ input that, when selected, allows the user to enter their desired page number.

screenshot

jQuery Joyride Feature Tour Plugin

This plugin is from ZURB, which is really all the info I need to know that it’s great. It helps you build little callouts that walk users through the features on your site one step at a time.

screenshot

Tooltips

jQuery PowerTip

A fairly robust and powerful jQuery tooltip plugin with plenty of options.

screenshot

tipsy

Another great tooltip plugin. This one is loosely based on giving you the ability to create Facebook-style tooltips.

screenshot

Slideshows, Images & Sliders

jQuery Slider Shock

A notably complete responsive jQuery / WordPress slider, with a wealth of options, settings, styles and functionality. Very well documented too!

screenshot

Backstretch

Backstretch creates dynamically-resized, slideshow-capable background images for any page or element.

screenshot

jQuery Anystretch

Anystretch is a jQuery plugin that allows you to add a dynamically-resized background image to any page or block level element. The image will stretch to fit the page/element, and will automatically resize as the window size changes.

screenshot

jQuery Lightbox

A simple lightbox based on prototype and scriptaculous.

screenshot

FlexSlider 2

FlexSlider is a responsive image slider from WooThemes with awesome features like multi-directional slide animations, semantic markup, touch support and the ability to include any HTML as a slide.

screenshot

ColorBox

Another simple lightbox plugin. Supports photos, grouping, slideshow, ajax, inline, and iframed content.

screenshot

WOW Slider

Literally one of the best, most powerful and fully featured sliders on the web. It’s responsive, has lots of different transitions and is packed with everything you could need. Go get it.

screenshot

Miscellaneous

Timeago

Quick, easy and auto-updating timestamps for jQuery. Example: About one day ago.

screenshot

jQuery Validation

The jQuery Validation Plugin provides drop-in validation for your existing forms, while making all kinds of customizations to fit your application really easy.

screenshot

jQuery File Upload Demo

A pretty robust file upload plugin for jQuery. Multiple file selection, drag&drop support, progress bars and preview images for jQuery.

screenshot

jQuery Instagram

Want to show an Instagram feed on your web page? With this little tool, you can.

screenshot

jQuery Shadow Plugin

Easily add all kinds of different shadows to your HTML elements. Each shadow takes very little code to implement.

screenshot

Naked Password

This one is ridiculous and potentially offensive, and a little hilarious. To encourage users to implement strong passwords, there’s a little, cartoony and non-detailed illustration (think NES) of a man or woman who gradually undresses as your password strength increases.

screenshot

MotionCAPTCHA

I hate mangled-word CAPTCHAs so much that I wrote an article about why we should kill them. This plugin provides a unique alternative that allows the user to bypass security by drawing shapes.

screenshot

jQuery Transit

Super-smooth CSS3 transformations and transitions for jQuery. Rotate, perspective, skew, scale and more.

screenshot

Web developers and designers may need these very helpful jQuery plugins, so I’ve compiled a list of 10+ jQuery Selectbox/Drop-down Plugins. Enjoy!

Update 12/12/2013: Added 16. Selectric.
Update 25/05/2013: Added 14. bootstrap-select & 15. jQuery selectBox.
Update 25/07/2012: Added 13. Multiple Select Box Plugin.
Update 15/07/2012: Added 12. ddSlick.
Update 05/04/2012: Added 11. Chosen.

 

Related Posts:

1. McDropDown

If you needed to develop a unique UI control that would allow users to select from a complex hierarchical tree of options, then this plugin is for you.


McDropDown

Source + Demo

2. LinkSelect

While there are many similar plugins, the key differentiator with the LinkSelect plugin is that is designed to fit in limited real estate.


LinkSelect

Source + Demo

3. Image Combo Box

If you tired with your old fashion selectbox try this one. Image combo box. You can add an icon with each option. It works with your existing “select” element.


Image Combo Box

Source Demo

4. jQuery Chained Select

To chain combobox state to combobox country and combobox city to combobox state you must write the following code.


jQuery Chained Select

Source Demo

5. QuickSelect

The QuickSelect plugin allows you to create a text input with a list of specified options, and as you type, those options show up in a list below the input box. You can choose to have it top result into the input box as you type, or select an option using the arrow keys.


QuickSelect

Source + Demo

6. jQuery Selectbox Plugin

Custom select box replacement inspired by jQuery UI source.


jQuery Selectbox

Source + Demo

7. Droplist Filter

This is a JavaScript tool for adding a little search widget next to any droplist.


Droplist Filter

Source + Demo

8. jQuery Searchable DropDown Plugin

A jQuery plugin which extends normal dropdown (select) elements to be searchable.


jQuery Searchable DropDown

Source Demo

9. Search Box with Filter

This search box reveals a drop down menu after the user clicks into the input field. The menu is meant to act as a filter with several checkbox options that allow the user to select specific categories for his search.


Search Box with Filter

Source Demo

10. Sexy Combo jQuery Plugin

A jQuery plugin that allows you to turn default browser selectboxes into much more attractive and usable comboboxes.


Sexy Combo jQuery Plugin

Source + Demo

11. Chosen jQuery Plugin

Chosen is a JavaScript plugin that makes long, unwieldy select boxes much more user-friendly. It is currently available in both jQuery and Prototype flavors.

chosen-jquery-plugin
Source + Demo

12. ddSlick jQuery Plugin

Good drop down plugin, adds images and description to otherwise boring drop downs.

ddslick
Source + Demo

13. jQuery Multiple Select Box Plugin


Demo

14. bootstrap-select

A custom select for @twitter Bootstrap using button dropdown.


dropdown1

Source + Demo

15. jQuery selectBox

A styleable replacement for SELECT elements


dropdown2

Source + Demo

15. jQuery Selectric

Selectric is a jQuery plugin designed to help at stylizing and manipulating HTML selects.


selectric

Source Demo

AUTHOR: . Find out more about jQuery4u author on Plus.

Courtesy:-http://www.jquery4u.com/plugins/10-jquery-selectboxdrop-down-plugins/


Below is the list of latest and updated jQuery interview questions and their answers for freshers as well as experienced users. These interview question covers latest version of jQuery which is jQuery 2.0. These interview questions will help you to prepare for the interviews, for quick revision and provide strength to your technical skills.
Courtesy:-http://www.codeproject.com/Articles/618484/Latest-jQuery-interview-questions-and-answers

 

Q1. What is jQuery?

Ans: jQuery is fast, lightweight and feature-rich client side JavaScript Library/Framework which helps in to traverse HTML DOM, make animations, add Ajax interaction, manipulate the page content, change the style and provide cool UI effect. It is one of the most popular client side library and as per a survey it runs on every second website.

Q2. Why do we use jQuery?

Ans: Due to following advantages.

  • Easy to use and learn.
  • Easily expandable.
  • Cross-browser support (IE 6.0+, FF 1.5+, Safari 2.0+, Opera 9.0+)
  • Easy to use for DOM manipulation and traversal.
  • Large pool of built in methods.
  • AJAX Capabilities.
  • Methods for changing or applying CSS, creating animations.
  • Event detection and handling.
  • Tons of plug-ins for all kind of needs.

 

Q3. How JavaScript and jQuery are different?

Ans: JavaScript is a language While jQuery is a library built in the JavaScript language that helps to use the JavaScript language.

Q4. Is jQuery replacement of Java Script?

Ans: No. jQuery is not a replacement of JavaScript. jQuery is a different library which is written on top of JavaScript. jQuery is a lightweight JavaScript library that emphasizes interaction between JavaScript and HTML.

Q5. Is jQuery a library for client scripting or server scripting?

Ans. Client side scripting.

Q6. Is jQuery a W3C standard?

Ans: No. jQuery is not a W3C standard.

Q7. What is the basic need to start with jQuery?

Ans: To start with jQuery, one need to make reference of it’s library. The latest version of jQuery can be downloaded from jQuery.com.

Q8. Which is the starting point of code execution in jQuery?

Ans: The starting point of jQuery code execution is $(document).ready() function which is executed when DOM is loaded.

Q9. What does dollar sign ($) means in jQuery?

Ans: Dollar Sign is nothing but it’s an alias for JQuery. Take a look at below jQuery code.

Collapse | Copy Code
$(document).ready(function(){
});

Over here $ sign can be replaced with “jQuery” keyword.

Collapse | Copy Code
jQuery(document).ready(function(){
});

Q10. Can we have multiple document.ready() function on the same page?

Ans: YES. We can have any number of document.ready() function on the same page.

Q11. Can we use our own specific character in the place of $ sign in jQuery?

Ans: Yes. It is possible using jQuery.noConflict().

Q12. Is it possible to use other client side libraries like MooTools, Prototype along with jQuery?

Ans: Yes.

Q13. What is jQuery.noConflict?

Ans: As other client side libraries like MooTools, Prototype can be used with jQuery and they also use $() as their global function and to define variables. This situation creates conflict as $() is used by jQuery and other library as their global function. To overcome from such situations, jQuery has introduced jQuery.noConflict().

Collapse | Copy Code
jQuery.noConflict();
// Use jQuery via jQuery(...)
jQuery(document).ready(function(){
   jQuery("div").hide();
});

You can also use your own specific character in the place of $ sign in jQuery.

Collapse | Copy Code
var $j = jQuery.noConflict();
// Use jQuery via jQuery(...)
$j(document).ready(function(){
   $j("div").hide();
});

Q14. Is there any difference between body onload() and document.ready() function?

Ans: document.ready() function is different from body onload() function for 2 reasons.

  1. We can have more than one document.ready() function in a page where we can have only one body onload function.
  2. document.ready() function is called as soon as DOM is loaded where body.onload() function is called when everything gets loaded on the page that includes DOM, images and all associated resources of the page.

 

Q15. What is the difference between .js and .min.js?

Ans: jQuery library comes in 2 different versions Production and Deployment. The deployment version is also known as minified version. So .min.js is basically the minified version of jQuery library file. Both the files are same as far as functionality is concerned. but .min.js is quite small in size so it loads quickly and saves bandwidth.

Q16. Why there are two different version of jQuery library?

Ans: jQuery library comes in 2 different versions.

  1. Production
  2. Deployment

The production version is quite useful at development time as jQuery is open source and if you want to change something then you can make those changes in production version. But the deployment version is minified version or compressed version so it is impossible to make changes in it. Because it is compressed, so its size is very less than the production version which affects the page load time.

Q17. What is a CDN?

Ans: A content delivery network or content distribution network (CDN) is a large distributed system of servers deployed in multiple data centers across the Internet. The goal of a CDN is to serve content to end-users with high availability and high performance.

Q18. Which are the popular jQuery CDN? and what is the advantage of using CDN?

Ans: There are 3 popular jQuery CDNs.

  1. 1. Google.
  2. 2. Microsoft
  3. 3. jQuery.

Advantage of using CDN.

  • It reduces the load from your server.
  • It saves bandwidth. jQuery framework will load faster from these CDN.
  • The most important benefit is it will be cached, if the user has visited any site which is using jQuery framework from any of these CDN

 

Q19. How to load jQuery from CDN?

Ans: Below is the code to load jQuery from all 3 CDNs.
Code to load jQuery Framework from Google CDN

Collapse | Copy Code
<script type="text/javascript"
    src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js">
</script>

Code to load jQuery Framework from Microsoft CDN

Collapse | Copy Code
<script type="text/javascript"
    src="http://ajax.microsoft.com/ajax/jquery/jquery-1.9.1.min.js">
</script>

Code to load jQuery Framework from jQuery Site(EdgeCast CDN)

Collapse | Copy Code
<script type="text/javascript"
    src="http://code.jquery.com/jquery-1.9.1.min.js">
</script>

Q20. How to load jQuery locally when CDN fails?

Ans: It is a good approach to always use CDN but sometimes what if the CDN is down (rare possibility though) but you never know in this world as anything can happen.

Below given jQuery code checks whether jQuery is loaded from Google CDN or not, if not then it references the jQuery.js file from your folder.

Collapse | Copy Code
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined')
{
  document.write(unescape("%3Cscript src='Scripts/jquery.1.9.1.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>

It first loads the jQuery from Google CDN and then check the jQuery object. If jQuery is not loaded successfully then it will references the jQuery.js file from hard drive location. In this example, the jQuery.js is loaded from Scripts folder.

Q21. What are selectors in jQuery and how many types of selectors are there?

Ans: To work with an element on the web page, first we need to find them. To find the html element in jQuery we use selectors. There are many types of selectors but basic selectors are:

  • Name: Selects all elements which match with the given element Name.
  • #ID: Selects a single element which matches with the given ID
  • .Class: Selects all elements which match with the given Class.
  • Universal (*): Selects all elements available in a DOM.
  • Multiple Elements E, F, G: Selects the combined results of all the specified selectors E, F or G.
  • Attribute Selector: Select elements based on its attribute value.

 

Q22. How do you select element by ID in jQuery?

Ans: To select element use ID selector. We need to prefix the id with “#” (hash symbol). For example, to select element with ID “txtName”, then syntax would be,

Collapse | Copy Code
$('#txtName')

Q23. What does $(“div”) will select?

Ans: This will select all the div elements on page.

Q24. How to select element having a particular class (“.selected”)?

Ans: $('.selected'). This selector is known as class selector. We need to prefix the class name with “.” (dot).

Q25. What does $(“div.parent”) will select?

Ans: All the div element with parent class.

Q26. What are the fastest selectors in jQuery?

Ans: ID and element selectors are the fastest selectors in jQuery.

Q27. What are the slow selectors in jQuery?

Ans: class selectors are the slow compare to ID and element.

Q28. How jQuery selectors are executed?

Ans: Your last selectors is always executed first. For example, in below jQuery code, jQuery will first find all the elements with class “.myCssClass” and after that it will reject all the other elements which are not in “p#elmID”.

Collapse | Copy Code
$("p#elmID .myCssClass");

Q29. Which is fast document.getElementByID(‘txtName’) or $(‘#txtName’).?

Ans: Native JavaScipt is always fast. jQuery method to select txtName “$('#txtName')” will internally makes a call to document.getElementByID('txtName'). As jQuery is written on top of JavaScript and it internally uses JavaScript only So JavaScript is always fast.

Q30. Difference between $(this) and ‘this’ in jQuery?

Ans: this and $(this) refers to the same element. The only difference is the way they are used. ‘this’ is used in traditional sense, when ‘this’ is wrapped in $() then it becomes a jQuery object and you are able to use the power of jQuery.

Collapse | Copy Code
$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert($(this).text());
  });
});

In below example, this is an object but since it is not wrapped in $(), we can’t use jQuery method and use the native JavaScript to get the value of span element.

Collapse | Copy Code
$(document).ready(function(){
    $('#spnValue').mouseover(function(){
       alert(this.innerText);
  });
});

Q31. How do you check if an element is empty?

Ans: There are 2 ways to check if element is empty or not. We can check using “:empty” selector.

Collapse | Copy Code
$(document).ready(function(){
    if ($('#element').is(':empty')){
       //Element is empty
  }
});

And the second way is using the “$.trim()” method.

Collapse | Copy Code
$(document).ready(function(){
    if($.trim($('#element').html())=='') {
       //Element is empty
  }
});

Q32. How do you check if an element exists or not in jQuery?

Ans: Using jQuery length property, we can ensure whether element exists or not.

Collapse | Copy Code
$(document).ready(function(){
    if ($('#element').length > 0){
       //Element exists
  });
});

Q33. What is the use of jquery .each() function?

Ans: The $.each() function is used to iterate over a jQuery object. The $.each() function can be used to iterate over any collection, whether it is an object or an array.

Q34. What is the difference between jquery.size() and jquery.length?

Ans: jQuery .size() method returns number of element in the object. But it is not preferred to use the size() method as jQuery provide .length property and which does the same thing. But the .length property is preferred because it does not have the overhead of a function call.

Q35. What is the difference between $(‘div’) and $(‘<div/>’) in jQuery?

Ans: $(‘<div/>’) : This creates a new div element. However this is not added to DOM tree unless you don’t append it to any DOM element.

$(‘div’) : This selects all the div element present on the page.

Q36. What is the difference between parent() and parents() methods in jQuery?

Ans: The basic difference is the parent() function travels only one level in the DOM tree, where parents() function search through the whole DOM tree.

Q37. What is the difference between eq() and get() methods in jQuery?

Ans: eq() returns the element as a jQuery object. This method constructs a new jQuery object from one element within that set and returns it. That means that you can use jQuery functions on it.

get() return a DOM element. The method retrieve the DOM elements matched by the jQuery object. But as it is a DOM element and it is not a jQuery-wrapped object. So jQuery functions can’t be used. Find out more here.

Q38. How do you implement animation functionality?

Ans: The .animate() method allows us to create animation effects on any numeric CSS property. This method changes an element from one state to another with CSS styles. The CSS property value is changed gradually, to create an animated effect.

Syntax is:

Collapse | Copy Code
(selector).animate({styles},speed,easing,callback)
  • styles: Specifies one or more CSS properties/values to animate.
  • duration: Optional. Specifies the speed of the animation.
  • easing: Optional. Specifies the speed of the element in different points of the animation. Default value is “swing”.
  • callback: Optional. A function to be executed after the animation completes.

Simple use of animate function is,

Collapse | Copy Code
$("btnClick").click(function(){
  $("#dvBox").animate({height:"100px"});
});

Q39. How to disable jQuery animation?

Ans: Using jQuery property “jQuery.fx.off“, which when set to true, disables all the jQuery animation. When this is done, all animation methods will immediately set elements to their final state when called, rather than displaying an effect.

Q40. How do you stop the currently-running animation?

Ans: Using jQuery “.stop()” method.

Q41. What is the difference between .empty(), .remove() and .detach() methods in jQuery?

Ans: All these methods .empty(), .remove() and .detach() are used for removing elements from DOM but they all are different.

.empty(): This method removes all the child element of the matched element where remove() method removes set of matched elements from DOM.

.remove(): Use .remove() when you want to remove the element itself, as well as everything inside it. In addition to the elements themselves, all bound events and jQuery data associated with the elements are removed.

.detach(): This method is the same as .remove(), except that .detach() keeps all jQuery data associated with the removed elements. This method is useful when removed elements are to be reinserted into the DOM at a later time.

Find out more here

Q42. Explain .bind() vs .live() vs .delegate() vs .on()

Ans: All these 4 jQuery methods are used for attaching events to selectors or elements. But they all are different from each other.

.bind(): This is the easiest and quick method to bind events. But the issue with bind() is that it doesn’t work for elements added dynamically that matches the same selector. bind() only attach events to the current elements not future element. Above that it also has performance issues when dealing with a large selection.

.live(): This method overcomes the disadvantage of bind(). It works for dynamically added elements or future elements. Because of its poor performance on large pages, this method is deprecated as of jQuery 1.7 and you should stop using it. Chaining is not properly supported using this method.

.delegate(): The .delegate() method behaves in a similar fashion to the .live() method, but instead of attaching the selector/event information to the document, you can choose where it is anchored and it also supports chaining.

.on(): Since live was deprecated with 1.7, so new method was introduced named “.on()”. This method provides all the goodness of previous 3 methods and it brings uniformity for attaching event handlers.

Find out more here

Q43. What is wrong with this code line “$(‘#myid.3’).text(‘blah blah!!!’);”

Ans: The problem with above statement is that the selectors is having meta characters and to use any of the meta-characters ( such as !”#$%&'()*+,./:;<=>?@[\]^`{|}~ ) as a literal part of a name, it must be escaped with with two backslashes: \\. For example, an element with id=”foo.bar”, can use the selector $(“#foo\\.bar”).
So the correct syntax is,

Collapse | Copy Code
$('#myid\\.3').text('blah blah!!!');

 

Q44. How to create clone of any object using jQuery?

Ans: jQuery provides clone() method which performs a deep copy of the set of matched elements, meaning that it copies the matched elements as well as all of their descendant elements and text nodes.

Collapse | Copy Code
$(document).ready(function(){
  $('#btnClone').click(function(){
     $('#dvText').clone().appendTo('body');
     return false;
  });
});

Q45. Does events are also copied when you clone any element in jQuery?

Ans: As explained in previous question, using clone() method, we can create clone of any element but the default implementation of the clone() method doesn’t copy events unless you tell the clone() method to copy the events. The clone() method takes a parameter, if you pass true then it will copy the events as well.

Collapse | Copy Code
$(document).ready(function(){
   $("#btnClone").bind('click', function(){
     $('#dvClickme').clone(true).appendTo('body');
  });

Q46. What is difference between prop and attr?

Ans: attr(): Get the value of an attribute for the first element in the set of matched elements. Whereas,.prop(): (Introduced in jQuery 1.6) Get the value of a property for the first element in the set of matched elements.

Attributes carry additional information about an HTML element and come in name=”value” pairs. Where Property is a representation of an attribute in the HTML DOM tree. once the browser parse your HTML code ,corresponding DOM node will be created which is an object thus having properties.

attr() gives you the value of element as it was defines in the html on page load. It is always recommended to use prop() to get values of elements which is modified via javascript/jquery , as it gives you the original value of an element’s current state. Find out more here.

Q47. What is event.PreventDefault?

Ans: The event.preventDefault() method stops the default action of an element from happening. For example, Prevents a link from following the URL.

Q48. What is the difference between event.PreventDefault and event.stopPropagation?

Ans: event.preventDefault(): Stops the default action of an element from happening.
event.stopPropagation(): Prevents the event from bubbling up the DOM tree, preventing any parent handlers from being notified of the event. For example, if there is a link with a click method attached inside of a DIV or FORM that also has a click method attached, it will prevent the DIV or FORM click method from firing.

Q49. What is the difference between event.PreventDefault and “return false”?

Ans: e.preventDefault() will prevent the default event from occurring, e.stopPropagation() will prevent the event from bubbling up and return false will do both.

Q50. What is the difference between event.stopPropagation and event.stopImmediatePropagation?

Ans: event.stopPropagation() allows other handlers on the same element to be executed, while event.stopImmediatePropagation() prevents every event from running. For example, see below jQuery code block.

Collapse | Copy Code
$("p").click(function(event){
  event.stopImmediatePropagation();
});
$("p").click(function(event){
  // This function won't be executed
  $(this).css("background-color", "#f00");
});

If event.stopPropagation was used in previous example, then the next click event on p element which changes the css will fire, but in case event.stopImmediatePropagation(), the next p click event will not fire.

Q51. How to check if number is numeric while using jQuery 1.7+?

Ans: Using “isNumeric()” function which was introduced with jQuery 1.7.

Q52. How to check data type of any variable in jQuery?

Ans: Using $.type(Object) which returns the built-in JavaScript type for the object.

Q53. How do you attach a event to element which should be executed only once?

Ans: Using jQuery one() method. This attaches a handler to an event for the element. The handler is executed at most once per element. In simple terms, the attached function will be called only once.

Collapse | Copy Code
$(document).ready(function() {
    $("#btnDummy").one("click", function() {
        alert("This will be displayed only once.");
    });
});​

Q54. Can you include multiple version of jQuery? If yes, then how they are executed?

Ans: Yes. Multiple versions of jQuery can be included in same page.

Q55. In what situation you would use multiple version of jQuery and how would you include them?

Ans: Well, it is quite possible that the jQuery plugins which are used are dependent on older version but for your own jQuery code, you would like to use newer version. So because of this dependency, multiple version of jQuery may required sometimes on single page.

Below code shows how to include multiple version of jQuery.

Collapse | Copy Code
<script type='text/javascript' src='js/jquery_1.9.1.min.js'></script>

<script type='text/javascript'>
 var $jq = jQuery.noConflict();
</script>

<script type='text/javascript' src='js/jquery_1.7.2.min.js'></script>

By this way, for your own jQuery code use “$jq”, instead of “$” as “$jq” refers to jQuery 1.9.1, where “$” refers to 1.7.2.

Q56. Is it possible to hold or delay document.ready execution for sometime?

Ans: Yes, its possible. With Release of jQuery 1.6, a new method “jQuery.holdReady(hold)” was introduced. This method allows to delay the execution of document.ready() event. document.ready() event is called as soon as your DOM is ready but sometimes there is a situation when you want to load additional JavaScript or some plugins which you have referenced.

Collapse | Copy Code
​
$.holdReady(true);
$.getScript("myplugin.js", function() {
     $.holdReady(false);
});

Q57. What is chaining in jQuery?

Ans: Chaining is one of the most powerful feature of jQuery. In jQuery, Chaining means to connect multiple functions, events on selectors. It makes your code short and easy to manage and it gives better performance. The chain starts from left to right. So left most will be called first and so on.

Collapse | Copy Code
​$(document).ready(function(){
    $('#dvContent').addClass('dummy');
    $('#dvContent').css('color', 'red');
    $('#dvContent').fadeIn('slow');
});​

The above jQuery code sample can be re-written using chaining. See below.

Collapse | Copy Code
​$(document).ready(function(){
    $('#dvContent').addClass('dummy')
          .css('color', 'red')
          .fadeIn('slow');     
});​

Not only functions or methods, chaining also works with events in jQuery. Find out more here.

Q58. How does caching helps and how to use caching in jQuery?

Ans: Caching is an area which can give you awesome performance, if used properly and at the right place. While using jQuery, you should also think about caching. For example, if you are using any element in jQuery more than one time, then you must cache it. See below code.

Collapse | Copy Code
$("#myID").css("color", "red");
//Doing some other stuff......
$("#myID").text("Error occurred!");
​

Now in above jQuery code, the element with #myID is used twice but without caching. So both the times jQuery had to traverse through DOM and get the element. But if you have saved this in a variable then you just need to reference the variable. So the better way would be,

Collapse | Copy Code
var $myElement = $("#myID").css("color", "red");
//Doing some other stuff......
$myElement.text("Error occurred!");
​

So now in this case, jQuery won’t need to traverse through the whole DOM tree when it is used second time. So in jQuery, Caching is like saving the jQuery selector in a variable. And using the variable reference when required instead of searching through DOM again.

Q59. You get “jquery is not defined” or “$ is not defined” error. What could be the reason?

Ans: There could be many reasons for this.

  • You have forgot to include the reference of jQuery library and trying to access jQuery.
  • You have include the reference of the jQuery file, but it is after your jQuery code.
  • The order of the scripts is not correct. For example, if you are using any jQuery plugin and you have placed the reference of the plugin js before the jQuery library then you will face this error.

Find out more here.

Q60. How to write browser specific code using jQuery?

Ans: Using jQuery.browser property, we can write browser specific code. This property contains flags for the useragent, read from navigator.userAgent. This property was removed in jQuery 1.9.

Q61. Can we use jQuery to make ajax request?

Ans: Yes. jQuery can be used for making ajax request.

Q62. What are various methods to make ajax request in jQuery?

Ans: Using below jQuery methods, you can make ajax calls.

  • load() : Load a piece of html into a container DOM
  • $.getJSON(): Load JSON with GET method.
  • $.getScript(): Load a JavaScript file.
  • $.get(): Use to make a GET call and play extensively with the response.
  • $.post(): Use to make a POST call and don’t want to load the response to some container DOM.
  • $.ajax(): Use this to do something on XHR failures, or to specify ajax options (e.g. cache: true) on the fly.

Find out more here.

Q63. Is there any advantage of using $.ajax() for ajax call against $.get() or $.post()?

Ans: By using jQuery post()/ jQuery get(), you always trust the response from the server and you believe it is going to be successful all the time. Well, it is certainly not a good idea to trust the response. As there can be n number of reason which may lead to failure of response.

Where jQuery.ajax() is jQuery’s low-level AJAX implementation. $.get and $.post are higher-level abstractions that are often easier to understand and use, but don’t offer as much functionality (such as error callbacks). Find out more here.

Q64. What are deferred and promise object in jQuery?

Ans: Deferred and promise are part of jQuery since version 1.5 and they help in handling asynchronous functions like Ajax. Find out more here.

Q65. Can we execute/run multiple Ajax request simultaneously in jQuery? If yes, then how?

Ans: Yes, it is possible to execute 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.

Using jQuery .when() method which provides a way to execute callback functions based on one or more objects, usually Deferred objects that represent asynchronous events. Find out more here.

Q66. Can you call C# code-behind method using jQuery? If yes,then how?

Ans: Yes. We can call C# code-behind function via $.ajax. But for do that it is compulsory to mark the method as WebMethod.

Q67. Which is the latest version of jQuery library?

Ans: The latest version (when this post is written) of jQuery is 1.10.2 or 2.0.3. jQuery 2.x has the same API as jQuery 1.x, but does not support Internet Explorer 6, 7, or 8.

Q68. Does jQuery 2.0 supports IE?

Ans: No. jQuery 2.0 has no support for IE 6, IE 7 and IE 8.

Q69. What are source maps in jQuery?

Ans: In case of jQuery, Source Map is nothing but mapping of minified version of jQuery against the un-minified version. Source map allows to debug minified version of jQuery library. Source map feature was release with jQuery 1.9. Find out more here.

Q70. How to use migrate jQuery plugin?

Ans: with release of 1.9 version of jQuery, many deprecated methods were discarded and they are no longer available. But there are many sites in production which are still using these deprecated features and it’s not possible to replace them overnight. So jQuery team provided with jQuery Migrate plugin that makes code written prior to 1.9 work with it.

So to use old/deprecated features, all you need to do is to provide reference of jQuery Migrate Plugin. Find out more here.

Q71. Is it possible to get value of multiple CSS properties in single statement?

Ans: Well, before jQuery 1.9 release it was not possible but one of the new feature of jQuery 1.9 was .css() multi-property getter.

Collapse | Copy Code
var propCollection = $("#dvBox").css([ "width", "height", "backgroundColor" ]);

In this case, the propCollection will be an array and it will look something like this.

Collapse | Copy Code
{ 
  width: "100px", 
  height: "200px", 
  backgroundColor: "#FF00FF" 
}

Q72. How do you stop the currently-running animation, remove all queued animations, and complete all animations for the matched elements?

Ans: It can be done via calling .stop([clearQueue ] [, jumpToEnd ]) method and by passing both the parameters as true.

Q73. What is finish method in jQuery?

Ans: The .finish() method stops all queued animations and places the element(s) in their final state. This method was introduced in jQuery 1.9.

Q74. What is the difference between calling stop(true,true) and finish method?

Ans: The .finish() method is similar to .stop(true, true) in that it clears the queue and the current animation jumps to its end value. It differs, however, in that .finish() also causes the CSS property of all queued animations to jump to their end values, as well.

Q75. Consider a scenario where things can be done easily with javascript, would you still prefer jQuery?

Ans: No. If things can be done easily via CSS or JavaScript then You should not think about jQuery. Remember, jQuery library always comes with xx kilobyte size and there is no point of wasting bandwidth.

Q76. Can we use protocol less URL while referencing jQuery from CDNs?

Ans: Yes. Below code is completely valid.

Collapse | Copy Code
<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>

Q77. What is the advantage of using protocol less URL while referencing jQuery from CDNs?

Ans: It is quite useful when you are moving from HTTP to HTTPS url. You need to make sure that correct protocol is used for referencing jQuery library as pages served via SSL should contain no references to content served through unencrypted connections.

“protocol-less” URL is the best way to reference third party content that’s available via both HTTP and HTTPS. When a URL’s protocol is omitted, the browser uses the underlying document’s protocol instead. Find out more here.

Q78. What is jQuery plugin and what is the advantage of using plugin?

Ans: A plug-in is piece of code written in a standard JavaScript file. These files provide useful jQuery methods which can be used along with jQuery library methods. jQuery plugins are quite useful as its piece of code which is already written by someone and re-usable, which saves your development time.

Q79. What is jQuery UI?

Ans: jQuery UI is a curated set of user interface interactions, effects, widgets, and themes built on top of the jQuery JavaScript Library that can be used to build interactive web applications.

Q80. What is the difference between jQuery and jQuery UI?

Ans: jQuery is the core library. jQueryUI is built on top of it. If you use jQueryUI, you must also include jQuery.

Jquery Photo Zoom Plugin

Posted: January 12, 2013 in Jquery, Must Watch

Introducing a new jQuery PhotoZoom plugin, it helps you to view bigger images on mouse over component, this is very useful for media related web applications. You can customize the PhotoZoom container based on your web page design. Very easy to implement just include the plugin using script tag and give required selector, take a look this live demo.
Jquery Photo Zoom Plugin



Download Script
     Live Demo

Author

Arun Kumar Sekar
Arun Kumar Sekar

Engineer, Plugin Expert
Chennai, INDIA

 

The Basic Setup

Include the jQuery and PhotoZoom plugin libraries into your document using script tag.

<script src=”jquery.js”></script>
<script  src=”photoZoom.min.js”> </script>
<script>
$(document).ready(function()
{
$(‘body’).photoZoom();
});
</script>
//HTML Code
<body>
<img src=’one.jpg’/>
<img src=’two.jpg’/>
……
……
</body>

You can customize container design by modifying CSS elements.

$(“body”).photoZoom(
{
zoomStyle : {
“border”:”1px solid #ccc”,
“background-color”:”#fff”,
“box-shadow”:”0 0 5px #888″
}
});

Here you can reuse onMouseOver and onMouseOut events.
$(“body”).photoZoom(
{
onMouseOver : function(currentImage){
// do something
},
onMouseOut : function(currentImage){
// do something
}
});

Courtesy:http://www.9lessons.info/2012/12/jquery-photo-zoom-plugin.html


1.Client-side jQuery pagination plugin : jPages

jPages is a client-side pagination plugin but it gives you a lot more features comparing to most of the other plugins for this purpose, such as auto page turn, key and scroll browse, showing items with delay, completely customizable navigation panel and also integration with Animate.css and Lazy Load.
Client-side jQuery pagination plugin : jPages

Read More Demo

2. jQuery ScrollPagination

jQuery ScrollPagination plugin has been developed by Anderson Ferminiano for studying purposes, you may use it for free in any project you want, only preserve the credits.
jQuery Scroll Pagination Plugin with Demo

Read More Demo

3. jqPagination A jQuery pagination plugin

jqPagination is a jQuery plugin that provides a newer method of pagination for your web site or application. Instead of displaying a list of page numbers like traditional pagination methods jqPagination uses an interactive ‘Page 1 of 5′ input that, when selected, allows the user to enter their desired page number. The plugin will ensure that only valid pages can be selected, a valid request will result in the paged callback. First, previous, next and last buttons work out of the box, but are optional.

jqPagination jQuery Pagination Plugin with Demo

Read More Demo

4. Extreme Makeover: jPaginator CSS3 Edition

jPaginator pagination aims to improve the user experience of long pagination lists by offering a slider to animate links left and right. In this tutorial, it teach you how to skin jPaginator into something beautiful.

jpaginator : jQuery Pagination Plugin with Demo

Read More Demo

5. Creating Modern jQuery Pagination for Content

I decided to create a new own jQuery plugin for pagination (for different content), which will be based not on the number of elements (childrens) per page, but will take care of the height of the content. And it will try to keep the same height for the pages. This means that the number of elements on the page can be different. Everything will depend on the height of these children. Plus, I will using fade effect to switch between pages.

jQuery Pagination For Content with example

Read More Demo

6. Sausage : jQuery infinite Pagination with Demo

Sausage is a jQuery UI widget for contextual pagination. It complements long or infinite-scrolling pages by keeping the user informed of her location within the document.

Sausage : jQuery infinite Pagination plugin with Demo

Read More Demo

7. Pagination with Jquery, PHP , Ajax and MySQL

Long days back I had posted an article Pagination with jQuery, MySQL and PHP with out refreshing page. Ravi Tamada modified old script and added extra features like First, Previous, Next and Last buttons. Use it and enrich your web applications.

Pagination with Jquery, PHP , Ajax and MySQL

Read More Demo

8. Smart Paginator : jQuery Pagination Plugin

Smart Paginator is a comprehensive jQuery Pagination plugin that makes adding pagination very simple task, all the navigation logic is built in and it is also very customizable. Smart Paginator can also filter your data automatically on client side. Click the screen shot below for the demonstration to see the various filter options provided by Smart Paginator. Smart Paginator supports variety of parameters and custom themes, that can be used to customize the look and feel to your desire.

Smart Paginator : jQuery Pagination Plugin with Demo

Read More Demo

9. How to create easy pagination with jQuery

All we know, that when we facing with necessarity to display large amount of data – we starting thinking about adding pagination. So we split all our content to several pages. And in this case – each page contain some part of our information. As usual this is server-side pagination, where we extracting necessary amount data from database for each page…

jQuery easy pagination with Demo

Read More Demo

10. Pagination with jQuery, MySQL and PHP

I received lot of requests from my readers that asked to me how to implement Pagination with jQuery, PHP and MySQL. so I had developed a simple tutorial. It’s looks big but very simple script.

Pagination with jQuery, MySQL and PHP and Demo

Read More Demo

11. Xarg : Ajax jQuery Pagination

Xarg jQuery Pagination plugin that has big advantage over server side pagination; by generating the links virtually on the client, the risk of duplicate content drops and the need of ugly follow, noindex link attributes left unnecessary. The pagination plugin also combines a varity of features. It can be used to divide long lists or areas of content into multiple seperate pages, load paged content with pre-calculated database offset-parameters via Ajax and anything with full control to adapt the style properly to your site-layout.

Xarg : Ajax jQuery Pagination with Demo

Read More Demo

12. Pajinate – A jQuery Pagination Plugin

Pajinate is a simple and flexible jQuery pagination plugin that allows you to divide long lists or areas of content into multiple separate pages. Not only is it a simpler alternative to server-side implementations, the time between paginated-page loads is almost nil (up to a reasonable page-size of course).

Pajinate – A jQuery Pagination Plugin with Demo

Read More Demo

13. jPaginate: A Fancy jQuery Pagination Plugin

jPaginate is a jQuery pagination plugin that comes with a twist: animated page numbers. The user can slide through the available page numbers by clicking or just hovering over the arrows. Shortlinks to the first and last page are available as well.

jPaginate: A Fancy jQuery Pagination Plugin with Demo

Read More Demo

14. SimplePager – jQuery paging plugin

SimplePager is to allow for creating pagination with as little effort or configuration as possible. This pager plugin can page divs, paragraphs, list items or almost any other content

SimplePager - jQuery paging plugin with example

Read More Demo

15. jPaginator: jQuery Pagination Plugin

jPaginator is a lightweight jQuery plugin (5kb) for pagination. It’s fun, intuitive, it comes with a slider and you can ask for an unlimited number of pages.

jPaginator: jQuery Pagination Plugin with Example & Demo

Read More Demo

16. jQuery Pagination Plugin

When you have a a large list of items (e.g. search results or news articles), you can display them grouped in pages and present navigational elements to move from one page to another. This plugin creates these navigational elements.

jQuery Pagination Plugin with example & demo

Read More Demo

17. Sweet Pages: A jQuery Pagination Solution

Today we are making a jQuery pagination plugin that will enable you to convert a regular unordered list of items into a SEO friendly set of easily navigatable pages. It can be used for comment threads, slideshows, or any kind of structured content.

Sweet Pages: A jQuery Pagination Solution with example & demo

Read More Demo

18. Easy pagination with jQuery and Ajax

In this tutorial I would like to go over an easy way to display your database data with jQuery using Ajax and pagination.If you would like a brief introduction to using Ajax with jQuery you can have a look at this tutorial. jQuery makes it very easy to send Ajax requests.

Easy pagination with jQuery Ajax and demo

Read More Demo

19. AJAX Pagination using jQuery and PHP with Animation

I have created an Ajax jQuery based pagination few months before which my users liked very much and there are thousands of downloads of that tutorial. So, I thought to create on another tutorial for pagination with some jquery effects to make stylish and attractive. Its animated loading of records using jquery animation. I hope you will like it very much as it looks nice.

AJAX Pagination using jQuery and PHP with Animation

Read More Demo

Best jQuery website

Courtesy: http://www.jqueryrain.com/2012/04/best-ajax-jquery-pagination-plugin-tutorial-with-example-demo/


1. Sonic – Looping Loaders

Sonic is a small (~3k minified) JS “class” you can use to create custom loading animations. It works best with looping animations — i.e. a snake that’s trying to eat its own tail.


Sonic

Source
Demo

2. Bouncy Animated Loading Animation

Just some funzies with CSS3 animations.


Bouncy Animated Loading Animation

Source
Demo

3. CSS3 Loading Spinners without Images

CSS transform (in Firefox 3.5+ and Webkit-based browsers) has a whole bunch of interesting functions, such as rotation, translation, scaling and skewing.


CSS3 Loading Spinners

Source + Demo

4. Ajax Style Loading Animation in CSS3 (no Images)

As we all know loading images are very essential part of any website , but some time loading images takes time to load itself, but what if the images made up in CSS. So this time I used CSS3 to develop Ajax style loading animation.


Ajax Style Loading

Source
Demo

5. CSS Loading Animation Circle Style

You can make animation for displaying the loading progress using clean CSS3 code. You can increase the size of the spheres by modifying the width and height in style classes: ul#transit li, .sphere and .beat.


CSS Loading Animation

Source
Demo

6. Flickr Style Loading Animation using JQuery

The flickr loading animation is simpler than the facebook style, it consist of two circles with different color, when the animation start the circle on the left move to right with on top display and vice versa.


Flickr Style Loading

Source
Demo

7. CanvasLoader Creator

The Heartcode CanvasLoader Creator is a free online tool which you can use to generate scripted preloaders (spinners or throbblers) for your HTML projects.


CanvasLoader Creator

Source + Demo

8. CSS3 Loading Animation

Three simple CSS3 Loading Animations.


CSS3 Loading Animation

Source
Demo

9. CSS3 Loading Animation Loop

Three CSS3 animation loop, can be used in many fields, such as preloader for images with jQuery.


CSS3 Loading Animation Loop

Source
Demo

10. PageLoading – jQuery Plugin

This jQuery plugin that will allow you to show a loading view during the loading of a web page. You will be able in a row and some parameters to customize the loading view. Its colors, loader icon, and the background image of the loading view.


PageLoading

Source

Courtesy: http://www.jquery4u.com/animation/10-css3-jquery-loading-animations-solutions/#.UBo8pfbiZcQ


I learned to make loading animation when I was learning flash, it was flash 5! Nowadays, we see it in HTML/CSS/JS websites, especially those are AJAX driven. Loading animation is extremely useful to letting users know that the server is processing the request. Do not under estimate it, it can make a website responsive to user interaction. It’s used as an indication of something is happening behind the scene, and inform users to wait for a while.

It usually in Animated Gif format, however, now, we have powerful browsers and technology (VML and Canvas), loading animation is no longer restricted in animated Gif format, it can be generated withJavascript and highly customisable. This time, I found 5 Javascript and following by 4 Animated Gif solutions to generate loading animation.

Javascript – VML & Canvas

I found total of 5 Javascript that generate loading animation. Unfortunately, not all of them can work in older browsers such as IE6, 7 and 8. However I found two Javascripts – activity indicator and spin.js that support both VML (IEs support) and Canvas (Modern browsers).

  • Activity IndicatorA jQuery plugin that renders a translucent activity indicator (spinner) using SVG or VML. This work almost the same with spin.js except it relies on jQuery.
    • Lightweight script
    • Resolution independent
    • Alpha transparency
    • Highly configurable appearance
    • Works in all major browsers
    • Uses feature detection
    • Degrades gracefully
  • Canvas LoaderThis plugin replaces typical animated gif loading image with a canvas based loader of the same width and height. This is super helpful when developing mobile apps that might be viewed on Android. It will also detect to see if you have canvas support before applying the replacement.
    • Limited styles, only work in browser with Canvas Support
  • Sonic Looping LoaderSonic is a small (~3k minified) JS “class” you can use to create custom loading animations. It works best with looping animations — i.e. a snake that’s trying to eat its own tail. This is a really cool javascript preloader, but unfortunately your browser need to support canvas.
    • Highly configurable, but only work with browsers with Canvas Support
    • Small file size ~3k minified
    • Customizable preloader style
  • HeartCode Canvas LoaderThe Heartcode CanvasLoader is a lightweight JavaScript UI library, which uses the HTML5 Canvas element to draw and animate circular preloaders.The Heartcode CanvasLoader runs in every ‘good’ browser which supports the HTML5 Canvas element.
    • Only work in browser with Canvas Support
    • An UI to customize preloader
  • Spin.jsSpin.js can be easily be the best among the rest because of its support of old browsers. It also come with an UI to customize your own preloader.
    • No dependencies (jQuery is supported, but not required)
    • Highly configurable
    • Resolution independent
    • Uses VML as fallback in old IEs
    • Uses @keyframe animations, falling back to setTimeout()
    • Works in all major browsers, including IE6
    • MIT License

Animated Gif Generators

Following by Animated Gif version. The difference between animated Gif version and Javascript version is GIF usually come with a lot of different designs.

That’s about it. When I was doing research about it, apparently it’s still a new solutions, not many Javascript plugins out there doing it. Thanks for reading, if you wish to know more about Javascript Plugins, Javascript driven websites and design inspirations.

Courtesy:http://www.queness.com/post/9150/9-javascript-and-animated-gif-loading-animation-solutions