Skip to content
Interview Shortout
  • Home
  • Articles
  • PHP
  • Python
  • Java Script
  • MySQL
  • Magento
  • Startups
  • Other

Top jQuery Interview Questions and Answers

Posted on March 26, 2018October 28, 2022 By Dhananjay No Comments on Top jQuery Interview Questions and Answers
Interview, Java Script, jQuery

What is jQuery?
jQuery is a Javascript library which uses usage of Javascript very easy.We can handle events, manage CSS properties, DOM element, animation and many more utilities using jQuery library.It is an opensource. It is used by Microsoft, Google, IBM and almost the big players in software industries.

What are selectors?
jQuery selectors are the tool to identify the HTML elements and to manipulate properties. for example:

$(".name") : Class selector
$('#logo') : ID selector
$("button") : tag selector
$(this) : current dom selector

What are the selectors that we use in jQuery?
We use the following selectors in jQuery:
-Tag
-Class
-Id
-all (*)
We can derive more selectors using these main selectors.

What is an event?
An event is a user action. When a user interacts using UI it has to make many clicks, drag, drop, mouse over, change drop down, keypress actions, these actions are recognized by jQuery.

What are the common events that user make?
Most common events make by users are :
-click
-mouseover
-keypress
-keydown
-change
-input
-drag
-drop
-blur
-dblclick (double click)
-mouseenter

What is toggle()?
toggle() is a function which provides switching functionality between two actions, functions, properties etc. Suppose we can show and hide an element using toggle function.

What is callback?
A callback is a function which is called after when execution finished. We have to specify which function we have to call after a particular execution.

What is alert()?
alert() is used as a callback to show some warning, notification or error.


$("button").click(function(){
        alert("Clicked on button");
});

What is chaining in jQuery?
Chaining is calling of multiple functions in a single statement. for example :

$(".button").css("color", "#ececec").slideUp(1000).slideDown(2000).hide();

How to get value or text of an HTML element?
Since we know jQuery can manipulate HTML DOM, we can use functions to get value, text or html block inside an HTML element. For example


$('.first_name').val();  //geting value in input box having class as first_name

$(‘p’).html(); //getting html inside a ‘p’ tag

$(‘textarea’).text(); //getting text inside a textarea

How can we set values or HTML element?
very similar to getting the value, we can set values to elements. For example:


$('.first_name').val('Interview Sortout Blogs');  //geting value in input box having class as first_name

$(‘p’).html(‘My blog is based on interview‘); //getting html inside a ‘p’ tag

$(‘textarea’).text(‘This blog is awesome. You are doing a verygood job,Interview Sortout’); //getting text inside a textarea

How to add or remove class from a HTML element?
jQuery have functions to add or to remove classes from an HTML elements. Please see the following examples:


$('button').addClass('btn-danger');
$('button').removeClass('btn-danger');

How to check that an element has a class?
We can use function hasClass().If class found it returns true, other wise returns false.


if($('button').hasClass('btn-danger')){
 alert('Button class is btn-danger');
}

What append() and prepend() functions do?
append() function , adds an HTML block after(at the end) a selector. For example :

$('p').append('Interview Sortout');

prepend() method, adds a block before or at the beginning of the selector. Example:

 

$('p').prepend('

Interview Sortout

‘);

What does parent() method do?
parent() method select the direct parent or immediate ancestor that is next to selector.

What does parents() method do?
parents() select all ancestors , the elements including parent of parent.

What childre() do?
children() method select the immediate child of the selector.

What does find() method do?
find() method search for the selector passed and selects from all the children of selector.

What does siblings() method do?
sibling() method returns all the elements having parralle relationship with selector. We can call them siblings.

How to call AJAX in jQuery?
An AJAX call example in jQuery:


var $post = $.ajax({
  url: "example.php",
  type: "POST",
  data: {id : product_id, product_name:product_name},
  dataType: "json"
});

$post.done(function(msg) {
$(“#log”).html( msg );
});

$post.fail(function() {
alert( “Request failed: Request Has been failed” );
});

More Java Script Related Interview questions and answers

  1. JSON Interview Questions and Answers
  2. Basic Java Script Interview Questions and Answers

 

Post navigation

❮ Previous Post: Drupal Interview Questions and Answers
Next Post: CSS Interview Questions and Answers ❯

Leave a Reply Cancel reply

You must be logged in to post a comment.

Doglapan

Recent Posts

  • Captable for Startups?
  • What is chat GPT?
  • All about Indexing in MySQL
  • Exploring the Growth and Future of Fintech Companies in Indian Startup Culture
  • Angel Investors in the Indian Startup Ecosystem: Understanding their Characteristics, Benefits and Role

Popular

AJAX artificial intelligence CakePHP Career Certifications CodeIgniter COVID Database Data Science DBMS DevOps Django Drupal ES6 Google Analytics HR Internship Interview Java Script jQuery Magento MVC MySQL PHP reactjs Risk Management Startups Training Visual Basic

Categories

  • AJAX
  • AJAX Interview Questions
  • Android
  • Articles
  • Artificial Intelligence
  • Banking
  • Big Data
  • Cake PHP Interview Questions
  • CakePHP
  • Career Guide
  • Certifications
  • CI/CD
  • Codeigniter Interview Questions
  • Codeigniter4
  • CSS
  • Data Science
  • DBMS
  • DevOps
  • Drupal
  • ES6 Interview Questions
  • Fresher Interview
  • Google Analytics
  • Gov Job
  • HR Interview
  • HTML
  • Internship
  • Interview
  • Java Script
  • jQuery
  • jQuery Interview Questions
  • JSON
  • Magento
  • MVC
  • MySQL
  • MySQL Interview Questions
  • OOPS
  • PHP
  • PHP Interview Questions
  • Python
  • Python Interview Questions
  • Reactjs Interview Questions
  • Resume
  • SEO
  • Startups
  • Visual Basic
  • WordPress
  • Wordpress Tutorial

Resources

  • Home
  • Paid Guest Post
  • About
  • Contact
  • Privacy Policy
  • DCMA
  • Home
  • Paid Guest Post
  • About
  • Contact
  • Privacy Policy
  • DCMA

Copyright © 2023 Interview Shortout.

Theme: Oceanly by ScriptsTown

Manage Cookie Consent
To provide the best experiences, we use technologies like cookies to store and/or access device information. Consenting to these technologies will allow us to process data such as browsing behavior or unique IDs on this site. Not consenting or withdrawing consent, may adversely affect certain features and functions.
Functional Always active
The technical storage or access is strictly necessary for the legitimate purpose of enabling the use of a specific service explicitly requested by the subscriber or user, or for the sole purpose of carrying out the transmission of a communication over an electronic communications network.
Preferences
The technical storage or access is necessary for the legitimate purpose of storing preferences that are not requested by the subscriber or user.
Statistics
The technical storage or access that is used exclusively for statistical purposes. The technical storage or access that is used exclusively for anonymous statistical purposes. Without a subpoena, voluntary compliance on the part of your Internet Service Provider, or additional records from a third party, information stored or retrieved for this purpose alone cannot usually be used to identify you.
Marketing
The technical storage or access is required to create user profiles to send advertising, or to track the user on a website or across several websites for similar marketing purposes.
Manage options Manage services Manage vendors Read more about these purposes
View preferences
{title} {title} {title}