Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
JQuery Interview Question Answer
04-22-2012, 09:41 AM
Post: #1
JQuery Interview Question Answer
1- What is jQuery ?
It's very simple but most valuable Question on jQuery means jQuery is a fast and concise JavaScript Library that simplifies HTML document traversing, animating, event handling, and Ajax interactions for rapid web development. jQuery is designed to change the way that you write JavaScript. Jquery is build library for javascript no need to write your own functions or script jquery all ready done for you

2- How you will use Jquery means requirement needed for using jquery?
Nothing more need to do just olny download jquery library(.js file) from any of the jquery site Download jquery and just linked with your html pages like all other javascript file

like below :
< script src="jquery.js" language="javascript" type="text/javascript">

3- what the use of $ symbol in Jquery?
$ Symbol is just replacement of jquery means at the place of $ you may use jquery hence $ symbol is used for indication that this line used for jquery

4- 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

5- 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):
     url: 'pcdsEmpRecords.php',
     success: function(response) {
     error: function(xhr) {
        alert('Error!  Status = ' + xhr.status);

6- 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() {
            url: 'pcdsEmpRecords.php',
            success: function(response) {
             // update div id Results

7- How do You disable or enable a form element?
There are two ways to disable or enable form elements.
Set the 'disabled' attribute to true or false:
// Disable #pcds
$('#pcds').attr('disabled', true);
// Enable #pcds
$('#pcds').attr('disabled', false);
Add or remove the 'disabled' attribute:
// Disable #pcds
$("#pcds").attr('disabled', 'disabled');
// Enable #x

8- How do you check or uncheck a checkbox input or radio button?
There are two ways to check or uncheck a checkbox or radio button.
Set the 'checked' attribute to true or false.
// Check #pcds
$('#pcds').attr('checked', true);
// Uncheck #pcds
$('#pcds').attr('checked', false);
Add or remove the 'checked' attribute:
// Check #pcds
$("#pcds").attr('checked', 'checked');
// Uncheck #pcds

9- How do you get the text value of a selected option?
Select elements typically have two values that you want to access. First there's the value to be sent to the server, which is easy:
// => 1
The second is the text value of the select. For example, using the following select box:
<select id="pcdsselect">
   <option value="1">Mr</option>
   <option value="2">Mrs</option>
   <option value="3">Ms</option>
   <option value="4">Dr</option>
   <option value="5">Prof</option>
If you wanted to get the string "Mr" if the first option was selected (instead of just "1"), you would do that in the following way:
$("#mpcdsselect option:selected").text();
// => "Mr"

[Image: 2604595733.png]
12-22-2012, 04:27 AM
Post: #2
RE: JQuery Interview Question Answer
Came to this post from google. Very good questions.

1) How does adding jquery js from google cdn differ from hosting it on server itself?
Ans: If you have website then it makes sense to add it from google cdn as it will get automatically downloaded. But if you have a application which will not run machines with internet connection then use locally hosted jquery js.
2) When and why should we use minified version of jquery js?
Ans: The minified version saves bandwidth and hence improves performance of the website/web application. The minified version is recommended to be used in production environment.

Possibly Related Threads...
Thread: Author Replies Views: Last Post
  WCF Interview Questions and Answer Shafiur Rahman 10 127,676 02-07-2014 09:36 AM
Last Post: anishrushi
  complete interview question/answer book nisar87 3 4,474 02-14-2013 06:35 AM
Last Post: anversadat21@gmail.com
  MVC asp.net interview question answer nisar87 1 58,971 01-07-2013 06:20 AM
Last Post: magnum_2007
  Jquery Question Answers nisar87 0 2,154 11-16-2012 08:22 PM
Last Post: nisar87
  MS SQL Server developer interview Question Shafiur Rahman 5 8,420 04-22-2012 06:04 AM
Last Post: jayanth2376

User(s) browsing this thread: 1 Guest(s)