Can't find the answer, I tried with what I found on this website and elsewhere but it never works. 

Goal : to trim white spaces before and after a word giving in the field DIV.

Problem : everything works fine as long there is NO white space before a word ! There can already be text in the DIV of it can be an empty DIV where text can be inserted.

I tried in the javascript in the DIV like **trim(this)** but that doesn't work. Even inthe script itself I tried **$.trim(editableObj.innerHTML)** , nor **editableObj.innerHTML.trim()**

Nothing works ! 

JS 

```
<script>
function showEdit(editableObj) {
  $(editableObj).css("background", "#FFF");
}

function saveToDatabase(editableObj, column, linkmainid, nav, linkid) {
  $(editableObj).css("background", "#FFF url(loaderIcon.gif) no-repeat right");
  $.ajax({
    url: 'save'+nav+'.php',
    type: "POST",
    data: 'linkcat=' + column + '&linktitle=' + editableObj.innerHTML + '&linkmainid=' + linkmainid + '&action=' + nav + '&linkid=' + linkid,
    success: function(data) {
      $(editableObj).css("background", "#FDFDFD");

      window.location="/website/cms/menu.php";
    }
  });
}

```

HTML 

```
<div class="navnew" contenteditable="true" onBlur="saveToDatabase(this,'1','999999','navnew','111')" onClick="showEdit(this);"></div>

```