Sunteți pe pagina 1din 7

1. What is jQuery?

jQuery is not a programming language but a well written JavaScript code. It is a JavaScript
code, which do document traversing, event handling, Ajax interactions and Animations.

2. Why jQuery is needed?

jQuery is needed for the following list:

 Used to develop browser compatible web applications


 Improve the performance of an application
 Very fast and extensible
 UI related functions are written in minimal lines of codes

3. Whether jQuery HTML work for both HTML and XML documents?

No, jQuery HTML only works for HTML documents not for XML Documents.

4. What are the methods used to provide effects?

Some of the effects methods are:

 Show()
 Hide()
 Toggle()
 FadeIn() and
 FadeOut()

5. What is the advantage of using minimized version of jQuery?

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.

6. Is jQuery is a JavaScript or JSON library file?

jQuery is a library of JavaScript file and it consists of DOM, event effects and the Ajax
functions. jQuery is said to be a single JavaScript file.

7. Which operating system is more compatible with jQuery?

Mac, Windows and Linux are more compatible with the jQuery.

9. Which command will give a version of jQuery?

The command $.ui.version returns jQuery UI version.

10. In what scenarios jQuery can be used?

jQuery can be used in following scenarios:


 Apply CSS static or dynamic
 Calling functions on events
 Manipulation purpose
 Mainly for Animation effects

11: What are the categories in jquery Events?


Answer: The common DOM events are as follows

 Form
 Keyboard
 Mouse
 Browser
 Document Loading

4: What is jQuery Ajax?


Answer: AJAX is an acronym standing for Asynchronous JavaScript and XML and this
technology helps us to load data and exchange data with the server without a browser page
refresh. JQuery is a great tool which provides a rich set of AJAX methods to develop next-
generation web applications.

5: What does ajax() method do?


Answer: This method sends an asynchronous http request to the server.

25. What are the four parameters used for jQuery Ajax method?

The four parameters are

 URL – Need to specify the URL to send the request


 type – Specifies type of request(Get or Post)
 data – Specifies data to be sent to server
 Cache – Whether the browser should cache the requested page

28. What is CDN?

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.

29. What are the two types of CDNs?

There are two types of CDNs:

 Microsoft – Load jQuery from Ajax CDN


 Google – Load jQuery from Google libraries API
30. Which sign is used as a shortcut for jQuery?

Dollar ($) sign is used as a shortcut for jQuery.

31. Is jQuery is a client or server scripting?

jQuery is a client scripting.

34. What are all the ways to include jQuery in a page?

Following are the ways to include jQuery in a page:

 Local copy inside script tag


 Remote copy of jQuery.com
 Remote copy of Ajax API
 Local copy of script manager control
 Embedded script using client script object

Question 8. How We Can Hide And Show The Controls In Jquery?


Answer :
Access the control using ‘$’ and use the methods “Hide()” and “Show()” like below.
For example:
$(‘#MyControl’).Hide()
$(‘#MyControl’).Show()

Question 9. How To Show The Alert Message On Button Click In Jquery?


Answer :
Jquery is one of the most powerful libraries what we have and it provides event handling. This
scenario can be handled by “OnClick” of the button. Below is the code snippet –
<input type=”button” id=”myButton” onclick=”alert(‘Hi’)” />

Question 10. What Is The Meaning Of Selectors In Jquery?


Answer :
In javascript we have several methods to find the controls like – “getElementByName” and
“getElementByID”, which is used to find the control based on Name of the control and ID of the
control respectively. Similarly in Jquery we have find the controls using selectors. Below are
some of the selectors -
o “*” - To Find all the elements of the page.
o “#” – Used to find the control by ID.
o “.” - Used to find the control by Class.

Question 13. Can You Give An Example Of Selecting An Element Based On Its Class
Name ?
Answer :
Below is the sample code snippet:
$(‘.MyControl’).Hide()

Question 17. How To Use Ajax In Jquery?


Answer :
Jquery supports AJAX calls, below is the code snippet of AJAX in Jquery –
$.ajax({
url: ‘MyURL',
success: function(response) {
//My Code goes here
},
error: function(err) {
//My Code goes here }
});

Question 8. How We Can Check/uncheck Radio Buttons In Jquery?


Answer :
Below is the code snippet to check/uncheck radio buttons:
// Check #mycontrolid
$('#mycontrolid').attr('checked', true);
// Uncheck #mycontrolid
$('#mycontrolid').attr('checked', false);

Question 5. Will Jquery Support Ajax ? Mention Some Ajax Methods Which Can Be Used
In Jquery?
Answer :
Yes. Jquery supports AJAX.
Below are some of the methods of AJAX:
o Get()
o Post()
o GetJSON()
o Ajax()

What is the difference between JavaScript and jQuery?

Under the hood jQuery is JavaScript but jQuery makes writing JavaScript code much easier.
For example if we want to select a div having id "container" then in plain JavaScript we will
write the following code.

var el = document.getElementById('container');

In jQuery we have to write the following to achieve the same result.

var el = $('#container');

What is $() in jQuery?

The $() is an alias of the jQuery() function.

If we pass a selector then it will return jQuery object with some methods which can be used to
perform different tasks.

In the following example we are selecting a div having id 'container' and hiding it from the page.

var el = $("#container");

el.hide();

How to execute jQuery code after the DOM is ready?

For this we write the following code.

$(document).ready(function() {

// some code goes here...

});

How will you include jQuery file in your HTML page?


We use the script tag and set the src attribute to the jQuery file.

In the following code we are including jQuery file from a CDN.

<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>

How will you make a GET request to the following API using jQuery?

API: https://api.github.com

For this we will use $.ajax() method.

In the following code we are making a GET request to the given API and printing the response in
the console.

$.ajax({

url: 'https://api.github.com',

method: 'GET',

success: function(data) {

console.log(data);

});

https://www.youtube.com/watch?v=melCBtSYQqU

S-ar putea să vă placă și