Introduction:

$(function () {
$('input[type=text]').focus(function ()
{
$(this).val('');
})
})
To
clear Particular textbox onfocus using jQuery:
$(function () {
$('#txtuser').focus(function ()
{
$(this).val('');
})
})
Full Source Code for Sample Application:
<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>
<fieldset style="width:300px">
<legend><strong>Listbox
Example</strong></legend>
<div>
<b>Enter Text:<br />
</b><br />
Name:
<input type="text" id="txtuser"
value="Enter Your
text" /><br /><br />
Company:
<input type="text" id="txtName"
value="Maziksolutions"
/>
</div></fieldset>
</body>
</html>
0 comments:
Post a Comment