61⟩ What features of jQuery, has been used in web applications?
jQuery uses features like Sliding, File uploading and accordion in web applications.
“jQuery Interview Questions and Answers guide is a simple way to learn jQuery. Here you will learn that jQuery is a fast, brief and smallest JavaScript Library that simplifies our HTML document traversing, its event handling, its animation, and Ajax interactions with application for rapid web development. jQuery is designed for the enhancement of JavaScript and AJAX. This jQuery Tutorial and Interview Questions and Answers will guide all of us that jQuery is a lightweight JavaScript library.”
jQuery uses features like Sliding, File uploading and accordion in web applications.
Browser compatibility of jQuery plugin is an issue and needs lot of time to fix it.
jQuery connect is a plugin used to connect or bind a function with another function. Connect is used to execute function from any other function or plugin is executed.
Connect can be used by downloading jQuery connect file from jQuery.com and then include that file in the HTML file. Use $.connect function to connect a function to another function.
jQuery.data methods is used to associate the data with the DOM nodes and the objects. This data method makes the jQuery code clear and concise.
Each function is used to iterate each and every element of an object. It is used to loop DOM elements, arrays and the object properties.
Efficiency of web page increases when minimized version of jQuery is used.min.js file will be more than 50% less than the normal js file. Reduction in the file size makes the web page faster.
Size and length both returns the number of element in an object. But length is faster than the size because length is a property and size is a method.
QUnit is used to test jQuery and it is very easy and efficient.
The jQuery filter is used to filter the certain values from the object list based on the criteria. Example is to filter certain products from the master list of products in a cart website.
CDN is abbreviated as Content Distribution network and it is said to be a group of companies in different location with network containing copies of data files to maximize bandwidth in accessing the data.
★ Google - Load jQuery from Google libraries API
★ Microsoft - Load jQuery from Ajax CDN
jQuery is a client scripting.
jQuery is a Javascript file and it is single javascript file that contains common DOM, event effects and Ajax functions.
Chaining is used to connect multiple events and functions in a selector.
There are two ways to debug jQuery:
Debugger keyword:
★ Insert a break point after attaching the process
★ Add the debugger to the line from where we have to start debugging and then run Visual Studio in Debug mode with F5 function key.
★ XPath Selector
★ Custom Selector
★ CSS Selector
In jQuery we have three methods to give the fade effect to elements: fadeIn, fadeOut and fadeTo
This methods change the opacity of element with animation.
Syntax:
$(selector).fadeIn(speed,callback)
$(selector).fadeOut(speed,callback)
$(selector).fadeTo(speed,opacity,callback)
"speed" can be one of following values : "slow", "fast", "normal" or milliseconds
"opacity" specify the value that allows the fading to given opacity.
"callback" is the function which we want to run once the fading effect is complete.
For example
$("clickme").click(function(){
$("mydiv").fadeTo("slow",0.50);
});
$("clickme").click(function(){
$("mydiv").fadeOut(3000);
});.
The animate function is used to apply the custom animation effect to elements.
Syntax:
$(selector).animate({params}, [duration], [easing], [callback])
"param" defines the CSS properties on which you want to apply the animation.
"duration" specify how long the animation will run. It can be one of following values : "slow", "fast", "normal" or milliseconds
"easing" is the string which specify the function for the transition.
"callback" is the function which we want to run once the animation effect is complete.
For example:
<div id="clickToAnimate">
Click Me
</div>
<div id="mydiv" style="width:200px; height:300px; position: relative; right: 20px;">
</div>
Following is the jQuery to animate opacity, left offset, and height of the mydiv element
$('# clickToAnimate').click(function() {
$('#book').animate({
opacity: 0.30,
left: '+=20',
height: 'toggle'
}, 3000, function() {
// run after the animation complete.
});
});
When we want to fetch siblings of every elements in the set of matched elements then we can use siblings() method.
We filter the elements fetched by an optional selector.
Syntax : .siblings( [selector])
"selector" is the selector expression which specify the matched elements.
For example:
<ul>
<li> item 1 </li>
<li id="second_item"> item 2 </li>
<li class="myitem"> item 3 </li>
<li class="myitem"> item 4 </li>
</ul>
Now we want to find the siblings of the element of id "second_item" and change the text color to Blue :
$('li.second_item').siblings().css('color','blue');
If we want specific sibling elements for example the elements having class "myitem" then we can pass a optional selector:
$('li.second_item').siblings('.myitem').css('color','blue');