JQuery Programmer

  Home  Client Side Scripting  JQuery Programmer


“JQuery Programmer Frequently Asked Questions in various JQuery Developer job Interviews by interviewer. The set of questions here ensures that you offer a perfect answer posed to you. So get preparation for your new job hunting”



154 JQuery Programmer Questions And Answers

84⟩ Give an example of closure?

Following example shows how the variable counter is visible within the create, increment, and print functions, but not outside of them −

function create() {

var counter = 0;

return {

increment: function() {

counter++;

},

print: function() {

console.log(counter);

}

}

}

var c = create();

c.increment();

c.print(); // ==> 1

 218 views

90⟩ Explain slideToggle() effect?

slideToggle() effect is used to give animated sliding effect to an element.

Syntax:

slideToggle([ duration] [, easing] [, callback])

1. "duration" is the number specifying how long the animation will run.

2. "easing" is the string which specify the function for the transition.

3. "callback" is the function which we want to run once the animation is complete.

4. If the element is visible then this effect will slide the element up side and make it completely hidden. If the element is hidden then slideToggle() effect will slide it down side and make it visible.

5. We can specify the toggle speed with this effect.

For example

$("#clickme").click(function()

{

$("#mydiv").slideToggle("slow", function()

{

//run after the animation is complete.

});

});

 234 views

96⟩ How to read, write and delete cookies using jQuery?

► To deal with cookies in jQuery we have to use the Dough cookie plugin.

► Dough is easy to use and having powerful features.

1. Create cookie

$.dough("cookie_name", "cookie_value");

2. Read Cookie

$.dough("cookie_name");

3. Delete cookie

$.dough("cookie_name", "remove");

 250 views

98⟩ What is jQuery.noConflict?

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().

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.

var $j = jQuery.noConflict();

// Use jQuery via jQuery(...)

$j(document).ready(function(){

$j("div").hide();

});

 233 views