javascript - Value of an html element edited -
why code not work in firefox? goal edited value when element loses focus
out = document.getelementbyid('out'); edit = function(e) { var element = e; element.contenteditable = true; element.onblur = function(blur) { console.log(element.innertext); out.innertext = element.innertext; }; }; span { background-color: cyan; } #out { background-color: yellow; padding: 0.5em; } <span ondblclick="edit(this)" data-foo="foo" data-bar="bar"> double-click , edit-me</span> <p></p> <span id="out"></span>
firefox doesn't support .innertext. should use w3 standard .textcontent instead.
this work in modern browsers , can patched ie8 if needed.
Comments
Post a Comment