Сообщение от Samsam
|
Вариант replace(/^\s+|\s+$/g, '');
|
<!DOCTYPE html>
<html>
<head>
<title>Untitled</title>
<meta charset="utf-8">
<style type="text/css">
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script>
<script>
$(function() {
$('.editor').html(function(i ,html) {
return html.replace(/ /g, '').replace(/^\s+|\s+$/g, '')
})
});
</script>
</head>
<body>
<div class="editor" contenteditable=""> test </div>
</body>
</html>