在我正在处理的页面上有一个包含单独div-id的div-id(dragZone),每个div包含一个图像 这些都是可拖动的,可调整大小的并且在点击时可以出现。
为了让.resizable正常工作,我填写了$('img')。可调整大小,但现在它正在影响页面上的所有其他图像。
任何想法如何使.resizable只能影响dragzone-id中的图像文件?
$(document).ready(function() {
var a = 3;
$('#dragZone > div').draggable({
start: function(event, ui)
{ $(this).css("z-index", a++); }})
$('img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
$('#dragZone > div').click(function() {
$(this).addClass('top').removeClass('bottom');
$(this).siblings().removeClass('top').addClass('bottom');
$(this).css("z-index", a++);
});
});
答案 0 :(得分:0)
更改
$('img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
到
$('#dragZone img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
这只会在dragZone div
中获取img答案 1 :(得分:0)
您还可以使用find
方法查找dragZone
内的图片元素:
$('#dragZone').find('img').resizable({maxHeight: 600, aspectRatio: true, animate: true });