jQuery

  Home  World Wide Web  jQuery


“jQuery Interview Questions and Answers guide is a simple way to learn jQuery. Here you will learn that jQuery is a fast, brief and smallest JavaScript Library that simplifies our HTML document traversing, its event handling, its animation, and Ajax interactions with application for rapid web development. jQuery is designed for the enhancement of JavaScript and AJAX. This jQuery Tutorial and Interview Questions and Answers will guide all of us that jQuery is a lightweight JavaScript library.”



91 JQuery Questions And Answers

45⟩ What is the use of jquery .each() function?

Basically, the jQuery .each() function is used to loop through each element of the target jQuery object. Very useful for multi element DOM manipulation, looping arrays and object properties.

Example:

In this example alert box will open 3 times because dom contain 3 <li> tags

<script>

$(document).ready(function(){

$("button").click(function(){

$("li").each(function(){

alert($(this).text())

});

});

});

</script>

<ul>

<li>Coffee</li>

<li>Milk</li>

<li>Soda</li>

</ul>

 214 views

46⟩ Suppose if you have a server control(asp.net server control, Button) and on the click of button you want to call a jquery function, So tell me how you will call a jquery function without postback?

ASP.NET provides the OnClientClick property to handle button clicks. You can use this property on Button, LinkButton and ImageButton. The same OnClientClick property also allows you to cancel a postback.

So I can use OnClientClick property and Jquery function will return false.

Example:

Code:

<script type="text/javascript">

function callMe()

{

alert('Hello');

return false;

}

</script>

<asp:Button ID="Button1" runat="server" OnClientClick="return callMe();" Text="Button" />

 259 views

50⟩ How to debug Jquery code/ debug jquery?

Add the keyword "debugger;" to the line from where we want to start the debugging and then run the Visual Studio in Debug mode by pressing F5 or using the Debug button.

 245 views

51⟩ How you get 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):

Code:

$.ajax({

url: 'pcdsEmpRecords.php',

success: function(response) {

alert(response);

},

error: function(xhr) {

alert('Error! Status = ' + xhr.status);

}

});

 193 views

53⟩ Why we need jQuery?

jQuery is needed for:

★ 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.

 198 views