.Net Interview Questions and Answers

Search:

What is the use of Document.ready in Jquery ? ( ASP.NET Jquery interview questions with answers)

By : Shiv Prasad Koirala | Sep 17th, 2013 | Views : 2953 | Comments : 0 Bookmark and Share

Do not forget to visit www.questpond.com for more such ASP.NET and jquery interview questions with answer videos.

 

"Document.Ready" event occurs once the complete HTML DOM is loaded. So the next question is when do we actually need this event?.Consider the below simple code where we are trying to set a text box "text1" with value "Sometext".

 

Now at the point when Jquery code tries set the textbox value , at that moment that text box is not available in the HTML DOM. So it throws an exception for the same.

 

<script>

      $("#text1").val("Sometext"); // Throws exception as the textbox is not //accessible at this moment

  </script>

</head>

<body>

<input type="text" id="text1" />

</body>

 

So we would like to execute the Jquery code which sets the textbox value only when all the HTML objects are loaded in DOM. So you can replace the code of setting text box value to something as shown below.

 

<script>

       $(document).ready(function()

           $("#text1").val("Sometext");

       });

  </script>

 

Also do read this Javascript Interview questions with answers :- How to debug Javascript ?

 

Below is a nice ASP.NET interview question , Do session use cookies ?

 

 
Rate this Article :
1 Star
2 Stars
3 Stars
4 Stars
5 Stars
1 1 1 2 1
 
 
 
 

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

.NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala

In this article we will explain .NET interview questions 6th edition (Sixth edition) - By Shivprasad Koirala.... Read More

Explain MVC application life cycle?

In this article we will explain MVC application life cycle.For more articles and videos visit us on www.questpond.com... Read More

What is the difference between Stored Procedures and Function (SQL Server interview question with answers)?

In this article we will explain what is the difference between Stored Procedures and Function.For more articles and videos visit us on www.questpond.com... Read More

C# Design pattern interview questions with answers: - How Singleton is different from Static class?

In this article we will explain How Singleton is different from Static class.... Read More

WCF interview questions and answers: - What is the difference between Service endpoint and Client endpoint?

In this article we will explain What is the difference between Service endpoint and Client endpoint.... Read More

Article Categories

Learn in Hindi