Skip welcome & menu and move to editor
Welcome to JS Bin
Load cached copy from
 
<!DOCTYPE html>
<html>
<head>
<script  src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
</head>
<body>
  <div id="foo">
    <span class="bar">Lorem ipsum dolor sit amet, consectetur adipisicing elit.</span>
  </div>
</body>
</html>
 
  #foo {
    overflow: hidden;
    text-overflow: ellipsis;
    width: 300px;
  }
  .bar {
    white-space: nowrap;
  }
 
    var foo = $("#foo");
    var max_width = foo.width();
    foo.children().each(function() {
      if ($(this).width() > max_width) {
        $(this).attr("title", $(this).text());
      }
    });
Output

This bin was created anonymously and its free preview time has expired (learn why). — Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers