Trying to edit the DOM manually will break things. Use MathQuill's API instead, like so:
$('.mathquill-editable').mathquill('latex', '');
Change $('.mathquill-editable')
to a more specific selector unless you want to clear every editable mathquill element on the page.
This will clear the content of textbox, and won't break it's function. However, the textbox will collapse into a tiny 6x6 pixel square, that won't expand to normal size unless the user clicks it. Certainly not dysfunctional, but not the prettiest either.
You can fix this by creating a custom key down event for the space key (source)
var space = $.Event('keydown');
space.bubbles = false;
space.cancelable = false;
space.charCode = 32;
space.keyCode = 32;
space.which = 32;
Note that the event is applied to mathquill's fake textarea on the interior, not the visible element itself.
$('.mathquill-editable').find('textarea').trigger(space);
Again, be sure the selector is specific to the element you wish to clear.
One last issue - the element won't be focused. Not sure if this is an issue for you, but the user will have to reselect the element to continue editing it. To fix that, you must apply the .focus()
method:
$('.mathquill-editable').find('textarea').focus();