Reputation: 2356
I have to display the text boxes and list boxes when click on the edit button. Please give suggestion to how to do that things.
HTML:
<div class="textboxes">
<ul>
<li><input type="text" id="txt" /></li>
<li><input type="text" id="txt" /></li>
<li><input type="text" id="txt" /></li>
</ul>
</div>
<input type="button" value="Edit" id="editBut" />
Javascript:
$("input[type='text']").blur(function(){
$(this).hide().after('<span class="dfk">' + $(this).val() + '</span>');
});
Here js fiddle : http://jsfiddle.net/thilakar/yvNuC/11/
Thanks
Upvotes: 1
Views: 8246
Reputation: 9309
Try this
$("#editBut").click(function() {
$('.textboxes span').hide();
$('.textboxes input[type=text]').show();
});
Check this DEMO
Upvotes: 1
Reputation: 30155
Here is it: http://jsfiddle.net/yvNuC/14/
$("#editBut").click(function() {
if ($('.textboxes').is(':visible')) {
$('.textboxes').hide();
// do save info
$(this).val('Edit');
}
else {
$('.textboxes').show();
$(this).val('Save');
}
});
Or if you need to display values after saving: http://jsfiddle.net/yvNuC/16/
Upvotes: 1