Last active
August 7, 2017 23:46
-
-
Save hail2u/c86ee1467cd132b1c011 to your computer and use it in GitHub Desktop.
`text-overflow: ellipsis`が指定されている要素の`title`属性へテキストを仕込む汎用スクリプト
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
/*! | |
* ellipsis-title.js | |
* | |
* LICENSE: http://hail2u.mit-license.org/2016 | |
*/ | |
"use strict"; | |
(function () { | |
var e; | |
var i; | |
var l; | |
var n = document.querySelectorAll("*"); | |
for (i = 0, l = n.length; i < l; i += 1) { | |
e = n[i]; | |
if (window.getComputedStyle(e)["text-overflow"] === "ellipsis") { | |
e.title = e.textContent; | |
} | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment