Logo F2FInterview

jQuery Interview Questions

Q   |   QA

First, include jQuery in your application.

Drop a textbox in your .aspx page:-

<input id="inputField" type="text" size="12"/>


include a button also:-

<asp:Button ID="Button1" runat="server" Text="get"/>


Now, here's the script:-

<script type="text/javascript">

$(document).ready(function () {

$('#Button1').click(function () {






On the click of the button, an alert will be given containing the text in the text box.

Generally in HTML, if we need to work with any control on a web page we need to find the control. For that we use document.getElementByID or document.getElementByName. But in jquery we do it using Selectors.

Using this selectors we can select all the controls as well using a symbol (* )

A sample code snippet can be of this form

<script language="javascript" type="text/javascript">

$("*").css("border", "10px red");



This will make all the borders in the web page with a width of 10 pixel and color as red.

Yes, it is always good to load your jquery from content delivery network. It provides some benefits like :-
(1) Caching - It means that if any previously visited site by user is using jQuery from Google CDN then the cached version will be used. It will not be downloaded again.
(2) Reduces load - It reduces the load on your web server as it downloads from Google server's.

Example :-

<script type="text/javascript"



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>

The advantage of using a minified version of JQuery file is Efficiency of the web page increases.

The normal version jQuery-x.x.x.js has a file size of 178KB

but the minified version jQuery.x.x.x-min.js has 76.7 KB.

The reduction in size makes the page to load more faster than you use a conventional jQuery file with 178KB

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: