41⟩ Is JQuery html() method works for both HTML and XML documents?
No, It only works for HTML.
“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.”
No, It only works for HTML.
No.
By $.ajax and by declaring method a WebMethod.
jQuery's data method gives us the ability to associate arbitrary data with DOM nodes and JavaScript objects. This makes our code more concise and clean.
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>
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" />
Jquery.size() and jquery.length both returns the number of element found in the object. But, jquery.length is faster than jquery.size() because size() is a method but length is a property.
jQuery-x.x.x.js = Pretty and easy to Read this one.
jQuery.x.x.x min.js = Looks like gibberish! But has a smaller file size. Put this one on your site for fast loading and less size.
Jquery's .size() method returns number of element in the object. That means that you can count the number of elements within an object.
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.
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);
}
});
We can add more than one document.ready() function in a page.
we can have only one onload function.
Document.ready() function is called as soon as DOM is loaded.
body.onload() function is called when everything (DOM, images)gets loaded on the page.
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.
Some effects methods are:
★ FadeIn()
★ FadeOut()
★ Show()
★ Hide()
★ Toggle()
No, if the Jquery file has been added to the master page then we can access the content page directly without adding any reference to it.
This can be done using this simple example:
<script type="text/javascript" src="jQuery-1.4.1-min.js"></script>
Mac, Windows and Linux are more compatible with the jQuery.
The command $.ui.version returns jQuery UI version.
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.
Find method is used to find all levels down the DOM tree but children find single level down the DOM tree.
Download the jQuery library from jQuery.com and include that reference in the asp.net page.