Introduction:
Here
I will explain How to use jQuery to clear textbox
value on focus or simple jQuery code snippet to
clear textbox value onfocus using jQuery.
Description:
In previous articles I explained jQuery Create Read Cookie Get Set Delete Cookies Example,jQuery Get Number of Facebook likes, Shares, Comments Count for Url or Website and many articles relating to JQuery, JavaScript, asp.net.. Now I will explain how to clear textbox value onfocus using jQuery.
Bind focus event for all textboxs to
clear values onfocus using jQuery
|
To
clear Particular textbox onfocus using jQuery
|
For
complete example check below code
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Clear Textbox onfocus using jQuery</title>
<script src="http://code.jquery.com/jquery-1.8.2.js"
type="text/javascript"></script>
<script type="text/javascript">
$(function () {
$('input[type=text]').focus(function () {
$(this).val('');
})
})
</script>
</head>
<body>
<div>
<b>Enter Text:</b>
<input type="text"
id="txtuser"
value="Welcome
to GohilInfotech.in" />
<input type="text"
id="txtName"
value="GohilInfotech.in"
/>
</div>
</body>
</html>
|
0 comments :
Post a Comment