Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在使用imgAreaSelect插件让用户裁剪图像。我想防止用户在没有裁剪图像的情况下点击保存按钮。如果图像已被裁剪,我正在寻找 javascript 中的解决方案,而不是检查服务器端。
从 imgAreaSelect API 中的示例:
$('img#photo').imgAreaSelect({ onSelectEnd: function (img, selection) { alert('width: ' + selection.width + '; height: ' + selection.height); } });
只需检查是否selection.width和selection.height是> 0
selection.width
selection.height
> 0