Disabling undo/redo in an HTML input field
I am using asp.net input fields and they automatically provide undo/redo functionality. I am using JavaScript to format the value of the input field, however this ruins the undo/redo history.
Is there a way to disable the开发者_开发百科 undo/redo feature?
or
- Is there a way to interact with the undo/redo history to add the correct values?
Using JavaScript, try replacing the text field with a new one and then setting the value. New field, new undo buffer, right?
jQuery:
$('#theTextField').after('<textarea id="theTextField2"></textarea>').remove();
$('#theTextField2').attr('id','theTextField');
I come up with this idea to remove the Undo/Redo to an input field using DOM manipulation and cloning, but make sure that the input is inside a parent node, this approach appends the newly cloned input field
I call this method on "onchange" event of the input... this is just a hack though.
function decup(e){
let new_ = e.target.cloneNode();
let parent_N = e.target.parentNode;
e.target.remove();
parent_N.appendChild(new_);
console.log(parent_N);
}
精彩评论