I have value attribute of an input. I need it to disappear on focus for that particular textbox, and reappear on blur, if the textbox has no content.
This is my current HTML code.
<label>First Name</label></td>
<input class="required" type="text" name="firstname" value="Fill" id="firstname" /><span>(required)</span>
Similarly i tried one other thing.When focus is in(Textbox A),a new textbox(B) appears and when focus is out(From A),B gets disappeared.But here is something wrong.I need the user to enter something in Box B also.Now i need something this.When focus is out from A as well B,only then B should disappear. Note:There are number of text box on the page. This is Code for it.
$('#lastname').focusin(function () {
$('input.hidden').fadeIn(1000);
$('input.hidden').css('backgroundColor', 'yellow');
}).focusout(function () {
$('input.hidden').hide();
});
Thanks in advance.
FIDDLE
If older browsers are'nt an issue, you don't really need javascript for this:
FIDDLE
Live example
Try:
Jsfiddle
You can then use
Jquery
to handlefocus
andBlur
event for yourtextbox
Live Demo