var all = [].slice.call(document.querySelectorAll('[data-tooltip]'));
var hoverdisplay = document.getElementsByClassName("hoverdisplay ")[0];
var inputbox = document.getElementsByTagName("textarea")[0];
var c = document.querySelector("#displaytext");
var space = document.createElement('span');
document.body.appendChild(space);
space.className = 'space';
space.innerHTML = ' ';
space.sizes = space.getBoundingClientRect();
var sheet = document.createElement('style');
sheet.innerHTML = ".space {width:" + space.sizes.width + "px; height:" + space.sizes.height + "px;}";
document.body.appendChild(sheet);
inputbox.addEventListener("input", function (b) {
/////////you shouldnt' need this because you have your input setup //////////////
var c = document.querySelector("#displaytext");
c.innerHTML = '';
[].slice.call(c.childNodes).forEach(function (d) {
c.removeChild(d);
});
var f = document.createElement('div');
inputbox.value.split("").forEach(function (d) {
var F = document.createElement('span');
F.className = 'space';
if (/\n/gim.test(d)) {
c.appendChild(f);
f = document.createElement('div');
return;
}
F = space.cloneNode(true);
F.dataset['tooltip'] = d;
F.textContent = d;
if (d.indexOf(' ') !== -1) {
F.innerHTML = ' ';
}
f.appendChild(F);
});
c.appendChild(f);
////////////////////shoudl need this stuff because of newlines and other things ///////////////
inputbox.scrollTop = 0;
inputbox.style.height = b.target.scrollHeight + "px";
/*updates the height so it should match when you hit enter*/
all = [].slice.call(document.querySelectorAll('[data-tooltip]'));
});
window.addEventListener("mousemove", (function (e) {
var hovered;
console.dir(e);
var mousex = e.clientX,
mousey = e.clientY;
hoverdisplay.style.top = mousey + "px";
...
Please Whitelist JSFiddle in your content blocker.
Help keep JSFiddle free for always by one of two ways:
Whitelist JSFiddle in your content blocker (two clicks)
Go PRO and get access to additional PRO features →
Join the 4+ million users, and keep the JSFiddle dream alive.
Ad-free
All ads in the editor and listing pages are turned completely off.
Use pre-released features
You get to try and use features (like the Palette Color Generator) months before everyone else.
Fiddle collections
Sort and categorize your Fiddles into multiple collections.
Private collections and fiddles
You can make as many Private Fiddles, and Private Collections as you wish!
Console
Debug your Fiddle with a minimal built-in JavaScript console.