全栈Web开发者我爱编程

jQuery 面试题(基础部分)(Only English)

2018-02-24  本文已影响35人  全栈开发之道

jQuery 面试题(基础部分) , 源自

https://www.javatpoint.com/jquery-interview-questions

序言

jQuery 是 JavaScript 的一个库,用一种更为简洁的方式操作 DOM 的元素。 jQuery 还算不上是一个前端框架, 因为它不支持模块的管理。 只有深谙 jQuery 后,你才会懂得 Angular、 React 、Vue 等前端框架的优越性所在。 先好好掌握jQuery 的基础概念吧!


jQuery Interview Question

A list of top frequently asked jQuery interview questions and answers are given below.

1) What is jQuery?

jQuery is a fast, lightweight, feature-rich client side JavaScript framework. It has provided a much needed boost to JavaScript. Before jQuery, JavaScript codes were lengthy and bigger, even for smaller functionality.


2) Is jQuery a programming language?

jQuery is not a programming language but a well written JavaScript code. It is used to traverse documents, event handling, Ajax interaction and Animation.


3) What is the difference between JavaScript and jQuery?

The simple difference is that JavaScript is a language while jQuery is a built-in library built of JavaScript. jQuery simplifies the use of JavaScript language.


4) Is jQuery replacement of JavaScript?

No, jQuery is not the replacement of JavaScript. jQuery is written on the top of JavaScript and it is a different library. jQuery is lightweight JavaScript library which is used to interact JavaScript and HTML.


5) Why do we use jQuery?


6) What are the effects methods used in jQuery?

These are some effects methods used in jQuery:


7) Is it possible that jQuery HTML work for both HTML and XML document?

No, jQuery HTML only works for HTML document. It doesn't work for XML documents.


8) What is $() in jQuery library?

The $() function is an alias of jQuery() function. It is used to wrap any object into jQuery object which later facilitates you to call various method defined jQuery object. You can pass a selector string to $() function and it will return jQuery object which contains an array of all matched DOM elements.


9) Is jQuery library used for server scripting or client scripting?

It is a library for client side Scripting.


10) Is jQuery a W3C standard?

No, jQuery is not a W3C standard.


11) What is the starting point of code execution in jQuery?

$(document).ready() function is the starting point of jQuery code. It is executed when DOM is loaded.


12) What is the basic requirement to start with the jQuery?

You need to make reference of its library to start with jQuery. You can download the latest version of jQuery from jQuery.com.


13) Can you use a special character in place of $ (dollar sign) in jQuery?

Yes.


14) Can you use multiple document.ready() function on the same page?

Yes. You can use any number of document.ready() function on the same page.


15) What is the difference between find and children methods?

Find method is used to find all levels down the DOM tree while children method is used to find single level down the DOM tree.


16) What is a CDN?

CDN stands for Content Delivery Network or Content Distribution Network. It is a large distributed systems of servers deployed in multiple data centers across the internet.


17) What is the goal of CDN and what are the advantages of using CDN?

The main goal of the CDN is to provide content to the end-users with high availability and high performance.

Advantages of using CDN:


18) How can you use jQuery library in your project?

You can use jQuery library in ASP.Net project from downloading the latest jQuery library from jQuery.com and include the references to the jQuery library file in your HTML/PHP/JSP/Aspx page.

  <script src="_scripts/jQuery-1.2.6.js" type="text/javascript"></script>   
 <script language="javascript">   
 $(document).ready(function() {   
  alert('test');   
  });   
</script>  

19) What are selectors in jQuery? How many types of selectors in jQuery?

If you want to work with an element on the web page, first you need to find it. Selectors are used to find the HTML elements in jQuery. There are many types of selectors. Some basic selectors are:


20) What is use of jQuery filter?

: jQuery filter is used to filter the certain values from the object. It filters the result of your original query into specific elements.


21) What are the different types of selectors in jQuery?

There are three types of selectors in jQuery:


22) What is the difference between ID selector and class selector in jQuery?

ID selector and class selector are same like they are used in CSS. ID selector uses ID while class selector uses class to select elements.

If you need to select just one element, use ID selector. If you want to select a group of elements, having same CSS class, use class selector.


23) How to add and remove CSS classes to an element using jQuery?

You can use addclass() jQuery method to add CSS class to an element and removeclass() jQuery method to remove CSS class from an element.


24) Can you write a jQuery code to select all links inside the paragraph?

Yes. You can use <a> tag nested inside paragraph <p> tag to select all links.


25) What is the difference between prop and attr?

attr(): It gets the value of an attribute for the first element in the set of matched element.

prop(): it gets the value of a property for the first element in the set of matched elements. It is introduced in jQuery 1.6.


26) What are the two types of CDNs?

There are two types of CDN:


27) What is the use of animate function in jQuery?

The animate function is used to apply the custom animation effect to elements. Syntax:

  1. $(selector).animate({params}, [duration], [easing], [callback])

Here,


28) How can you disable jQuery animation?

By using jQuery property "jQuery.fx.off" and setting it to true, you can disable jQuery animation.

小结

HTML、 CSS、 JavaScript 是 前端工程师的三大法宝。 而 jQuery 是操作 DOM的利器。 按说呢, 通过原生的 JavaScript 也可以操作DOM, 比如: document.getElementByID () ; 相比 jQuery 还是麻烦了很多。


参考书: 《 全栈开发之道:MongoDB+Express+AngularJS+Node.js

更多全栈技术,请关注微信公众号: “全栈工程师的早读课”,每天早8:00 准时推送技术文章。

上一篇 下一篇

猜你喜欢

热点阅读