This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Wraps a string around each character/letter | |
* | |
* @param {string} str The string to transform | |
* @param {string} tmpl Template that gets interpolated | |
* @returns {string} The given input as splitted by chars/letters | |
*/ | |
function wrapChars(str, tmpl) { | |
return str.replace(/\w/g, tmpl || "<span>$&</span>"); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var el = document.querySelector('.el'), | |
btn = document.querySelector('.btn-edit'); | |
el.addEventListener('input', function (e) { | |
console.log(e.currentTarget.textContent); | |
}); | |
btn.addEventListener('click', function () { | |
var isEditing = el.getAttribute('contenteditable'); | |
NewerOlder