Hi try this...
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('#myTextBox').click(function(){
$('#myTextBox').val("");
});
$('#myTextBox').blur(function(){
var currentText = $('#myTextBox').val();
if(currentText == "")
{
$('#myTextBox').val("Enter text");
}
});
});
</script>
</head>
<body>
<input type="text" id="myTextBox" value="Enter text">
</body>
@developer
Junior Poster in Training
70 posts since Nov 2010
Reputation Points: 13
Solved Threads: 10
Hi minimogul,
There are lots of jQuery tutorials available, me also a beginner in this. You can start learning from the official jQuery site http://docs.jquery.com/Tutorials . Also checkout the API reference given.
This can be used for multiple text boxes.
<head>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.4.4.min.js"></script>
<script type="text/javascript">
$(document).ready(function(){
$('input:text').click(function(event){
$(event.target).val("");
});
$('input:text').blur(function(event){
if($(event.target).val() == "")
{
$(event.target).val("Enter text");
}
});
});
</script>
</head>
<body>
<input type="text" id="myTextBox" value="Enter text">
<input type="text" id="myTextBox2" value="Enter text">
<input type="text" id="myTextBox3" value="Enter text">
</body>
@developer
Junior Poster in Training
70 posts since Nov 2010
Reputation Points: 13
Solved Threads: 10