<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>自動為text-overflow ellipsis加上title顯示</title>
<style>
.a-ellipsis {
width: 100%;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
div { padding: 3px; }
</style>
</head>
<body>
<div style="width: 120px">
<div class="a-ellipsis">如何讓你遇見我</div>
<div class="a-ellipsis">在我最美麗的時刻 為這</div>
<div class="a-ellipsis">我已在佛前求了五百年</div>
<div class="a-ellipsis">求他讓我們結一段塵緣</div>
</div>
<script src="https://code.jquery.com/jquery-2.1.4.js"></script>
<script>
$(function() {
$("body").on("mouseenter", ".a-ellipsis", function() {
if (!this.title) this.title = $(this).text();
});
});
</script>
</body>
</html>