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
<textarea id='disText' disabled="disabled"></textarea> <button id='disAble'>Edit</button>
Js:
$('button#disAble').on('click', function(){ $('textarea#disText').prop('disabled', false); $(this).text('submit'); //submit stuff });