我正在按照下面的 css 来调整 div 的大小。现在我需要知道用户为 div 选择了多少宽度。
有没有可能做到这一点?
<html>
<head>
<style>
div {
border: 2px solid;
padding: 20px;
width: 300px;
resize: horizontal;
overflow: auto;
}
</style>
</head>
<body>
<p><b>Note:</b> Internet Explorer does not support the resize property.</p>
<div>Let the user resize both the height and the width of this div element.</div>
</body>
</html>
最佳答案
$( window ).resize(function() { // this to get windows width
console.log( $( window ).width() );
});
$('#div-resizable').resize(function() { // this to get div width
console.log( $(this).width() );
});
关于javascript - 如何将可调整大小的 div 宽度读取到变量中 - Angular 4,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48049843/