Introduction:
Here I will explain How to use jQuery
to clear textbox value or simple jQuery
code snippet to clear textbox value using jQuery.
Description:
In previous posts I explained jQuery allow alphabetic characters in textbox, jQuery Allow only numbers in textbox, jQuery disable cut copy and paste options in textbox, jQuery Create Rounded Corners Textbox, jQuery slideUp, slideDown and slideToggle Example and many articles relating to JQuery, JavaScript, Asp.net. Now I will explain how to clear textbox value using jQuery.
To clear all textbox values using jQuery we
need to write the code like as shown below
|
To clear Particular textbox using jQuery we
need to write the code like as shown below
|
For complete example check below code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Clear
Textbox using jQuery</title>
<script src="http://code.jquery.com/jquery-1.8.2.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function ()
{
$('#btnClear').click(function () {
$('input[type=text]').each(function () {
$(this).val('');
})
})
$('#btnclr').click(function () {
$('#txtuser').val('');
})
})
</script>
</head>
<body>
<div>
<b>Enter
Text:</b>
<input type="text"
id="txtuser"
/>
<input type="text"
id="txtName"
/>
<input type="button"
id="btnclr"
value="Clear
First Textbox" />
<input type="button"
id="btnClear"
value="Clear All
Textboxes" />
</div>
</body>
</html>
|
Live Demo
To check live demo try to enter text in below textboxes
and click on buttons
|
If you enjoyed this post, please support the blog below. It's FREE! Get the latest Asp.net, C#.net, VB.NET, jQuery, Plugins & Code Snippets for FREE by subscribing to our Facebook, Twitter, RSS feed, or by email. |
|||
|
|||
4 comments :
nice
nice blog for readers.
Sir, How to print the content of div using javascript? pls help me
sorry but my code is not working
Note: Only a member of this blog may post a comment.