I have a textbox in my HTML file. It is basically a comment box. I want it to function such that it is in disabled state normally. But when someone clicks a ‘EDIT’ button it should allow them to modify the value in the textbox. On clicking the EDIT button, I would either like to display a new SUBMIT button or change the EDIT button to SUBMIT button itself.
Can someone give me some sample code. I know the code would be quite easy, but I am very bad with JavaScript.
Advertisement
Answer
JavaScript
x
3
1
<textarea id='disText' disabled="disabled"></textarea>
2
<button id='disAble'>Edit</button>
3
Js:
JavaScript
1
6
1
$('button#disAble').on('click', function(){
2
$('textarea#disText').prop('disabled', false);
3
$(this).text('submit');
4
//submit stuff
5
});
6