Home
Jquery
Interview FAQs

FAQs of level

Using "isNumeric()" function which was introduced with jQuery 1.7.

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

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.

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

You want to use the shortcut $ alias instead of typing the global namespace name (jQuery) without fear of global conflicts. The solution here is to create an anonymous self-invoking function that we pass the jQuery object to and then use the $ character as a parameter pointer to the jQuery object.
For example, all jQuery code could be encapsulated inside the following self-invoking function:
(function($){ //function to create private scope with $ parameter
//private scope and using $ without worry of conflict
})(jQuery); //invoke nameless function and pass it the jQuery object

You need to select elements based on their order among other elements.These may look like CSS pseudo classes, but in jQuery they are called filters:
:first - Matches the first selected element
:last - Matches the last selected element
:even - Matches even elements (zero-indexed)
:odd - Matches odd elements (zero-indexed)
:eq(n) - Matches a single element by its index (n)
:lt(n) - Matches all elements with an index below n
:gt(n) - Matches all elements with an index above n
Syntax:
jQuery("ul li").filter(":first");

Chaining is one of the most powerful features 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.

$(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.
$(document).ready(function(){
$("#dvContent").addClass("dummy")
.css("color", "red")
.fadeIn("slow");
});

Not only functions or methods, chaining also works with events in jQuery.

Chaining is one of the most powerful features 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.
$(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.
$(document).ready(function(){
$("#dvContent").addClass("dummy")
.css("color", "black")
.fadeIn("slow");
});

Not only functions or methods, chaining also works with events in jQuery.

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.

$(document).ready(function(){
$("#btnClone").click(function(){
$("#dvText").clone().appendTo("body");
return false;
});
});

PreviousDisplaying 7 of 7
1 2 3 4 5 6 7
Need Help? Contact Us.

Log in

*
*

Forgot password?

*

New User

*
*
*
*