JQuery Interview Questions & Answers part 1

0
355

Q: – What is JQuery?

JQuery is Java Script library or Java Script Framework which helps in how to traverse HTML documents, do some cool animations, and add Ajax interaction to any web page. It mainly helps programmer to reduce lines of code as huge code written in Java Script, can be done easily with JQuery in few lines.

Q: – What does dollar Sign ($) means in JQuery?

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

$(document).ready(function(){
});
Over here $ sign can be replaced with "jQuery " keyword.
jQuery(document).ready(function(){
});

Q: – How is body onload() function is different from document.ready() function used in jQuery?

Document.ready() function is different from body onload () function because off 2 reasons.
1. We can have more than one document.ready() function in a page where we can have only one 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.

Q: – What are the steps you need to follow to use jQuery in ASP.Net project?

It's really simple. One just need to add reference of javascript file(.js). Go to Jquery.com and download the latest version of jQuery. When download is completed, there is a "jQuery-1.3.2.js" in the folder. Include this file
<script src="_scripts/jQuery-1.3.2.js" type="text/javascript"></script>
and you good to go now for JQuery.
Note : 1.3.2 denotes the library version.. It can be vary depending upon the version of Jquery you download.

Q: – tell me name of 3 types of selectors in Jquery?

1. CSS Selector
2. XPath Selector
3. Custom Selector

Q: – What is the basic used of jQuery() function

->Establish code to be executed when the DOM is ready for manipulation.
->Help as a namespace for global utility functions.
->Create DOM elements from HTML markup.
->Select and wrap DOM elements to operate upon

Q: – which are basic selectors in jQuery (cross browser)?

->Element ID's
->CSS class name
->Tag name
->last but not the least DOM hierarchy.

Q: – How do you select an item using css class or ID and get the value by use of jquery

If an element of html like < div> , < p> or any tag have ID MyId and class used MyClass then we select the element by below jquery code
$('#MyId') for ID and for classs $('.MyClass') and for value
var myValue = $('#MyId').val(); // get the value in var Myvalue by id
Or for set the value in selected item
$('#MyId').val("print me"); // set the value of a form input

Q: – >How to get the server response from an AJAX request using Jquery?

When invoking functions that have asynchronous behavior We must provide a callback function to capture the desired result. This is especially important with AJAX in the browser because when a remote request is made, it is indeterminate when the response will be received.
Below an example of making an AJAX call and alerting the response (or error):
$.ajax({
url: 'pcdsEmpRecords.php',
success: function(response) {
alert(response);
},
error: function(xhr) {
alert('Error!  Status = ' + xhr.status);
}
});

Q: – How do you update ajax response with id " resilts"

By using below code we can update div content where id 'results' with ajax response
function updateStatus() {
$.ajax({
url: 'pcdsEmpRecords.php',
success: function(response) {
// update div id Results
$('#results').html(response);
}
});
}

Submitted By:-Uma           Email-ID: – kumariuma44@yahoo.in

SHARE

LEAVE A REPLY