I would like to create a textbox upon clicking a hyperlink within the body of a webpage.
Scenario:
The user visits the page and is asked a number of questions, they can choose to answer any number of them. To do so, they click on the question (which is formatted as a link so it is clear that you click on it) then a textbox appears. Upon entering the desired answer and hitting enter/on focusout etc the hyperlink is replaced with the resulting text.
I have seen this JSFiddle which was from this question but it doesn't accomplish the desired effect. (code below - not mine)
HTML
<div class="control-group">
<label for="name" class="control-label">
<p class="text-info">Saghir<i class="icon-star"></i></p>
</label>
<input type="text" class="edit-input" />
<div class="controls">
<a class="edit" href="#">Edit</a>
</div>
</div>
JavaScript
$(document).ready(function() {
$('a.edit').click(function () {
var dad = $(this).parent().parent();
dad.find('label').hide();
dad.find('input[type="text"]').show().focus();
});
$('input[type=text]').focusout(function() {
var dad = $(this).parent();
$(this).hide();
dad.find('label').show();
});
});
CSS
.edit-input {
display:none;
}