【发布时间】:2015-02-09 05:54:02
【问题描述】:
问题是,如果将这些具有生成 ID“cam_snap_XXX”的图像拖放到该区域中,我需要它们变成不同的宽度。我可以改变高度,但不能改变宽度,因为如果 x==1,宽度被指定为 20px。从来没有指定图像高度,因此我相信这是它可变的原因?问:如果“拖动”,如何使这些图像宽度从 20px 变为 100px?
while (cnt <= 100) {
cam_icon=document.getElementById('cam_snap_' + cnt);
cam_icon.style.visibility = 'hidden';
if (x==1) {
cam_icon.style.width = '20px';
cam_icon.style.visibility = 'visible';
}
cnt++;
}
高度从以下javascript变化...
//js for adding class "dragged" which gives new height and width image parameters
$('.droparea td.drop').droppable({
onDrag: function (e, source) {
$(this).addClass('dragged'); //Changes height correctly not width though.
}
}
还有 css..
//css for attempting to change image width and height on drop
.dragged{
height: 100px; //Works because height stretches image height from ~20px to 100px.
width: 100px; //**Doesn't work and is useless because width remains 20px.**
}
在向这些图像添加“拖动”类之前,我是否应该尝试删除该类?使用 removeClass()?即使不是解决方案,也欢迎任何想法。
【问题讨论】:
标签: javascript jquery css addclass classname