If i have to enter any value in that text box and press tab button. text box will remove and value should be display. like this way $('#txt').val();
Please help me how to do?
Shooting from the hip here. Is this what you are looking for?
$('input[type="text"]').blur(function() {
$(this).hide().after($('<span>').text($(this).val()));
});
$('input[type="text"]').keydown(function (e) {
if (e.keyCode == 9) {
$(this).hide().after($('<span>').text($(this).val()));
}
});
<div>
<input type='text' id='txt'>
</div>
//If you don't require a tab push
$('#txt').live('blur'){
var value = $(this).val();
if(value){
$(this).parent().html(value);
}
}
//If you want tab only
$('#textbox').live('keydown', function(e) {
var keyCode = e.keyCode || e.which;
if (keyCode == 9) {
e.preventDefault();
var value = $(this).val();
if(value){
$(this).parent().html(value);
}
}
});
As others have stated, if you can't change your HTML markup to conform above...
$('#txt').blur(function(){
$(this).hide().after($(this).val());
});
Try this:
$('#txt').blur(function(){
$(this).hide().after($(this).val());
});
Working example: http://jsfiddle.net/AlienWebguy/Jdf5m/1/