Код: Выделить всё
$(document).ready(function() {
$("button").click(function() {
alert("Width of #text: " + $("#text").width());
});
});
Код: Выделить всё
* {
margin: 0;
padding: 0;
font-family: sans-serif;
}
#container {
width: 300px;
height: 150px;
background-color: grey;
position: relative;
}
#scroll-area {
overflow-x: auto;
height: 100%;
}
#text {
white-space: nowrap;
}
Код: Выделить всё
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
Get width of #text
Я хотел бы вычислить ширину #text элемент, находящийся внутри элемента #container. В настоящее время в результате отображается 300 пикселей. Но это ширина контейнера, а не текстового элемента.
Подробнее здесь: https://stackoverflow.com/questions/716 ... -auto-area