【问题标题】:excluding img files from the .resizable 'img' function从 .resizable 'img' 函数中排除 img 文件
【发布时间】:2012-05-07 21:05:41
【问题描述】:

在我正在处理的页面上有一个 div-id (dragZone),其中包含单独的 div-id,每个 div-id 包含一个图像 这些都是可拖动的、可调整大小的,并且在点击时会出现。

为了让 .resizable 起作用,我填写了 $('img').resizable 但这现在当然会影响页面上的所有其他图像。

知道如何使 .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++);

});
});    

【问题讨论】:

    标签: jquery draggable resizable


    【解决方案1】:

    你也可以使用find方法在dragZone里面找到图片元素:

    $('#dragZone').find('img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
    

    【讨论】:

      【解决方案2】:

      改变

      $('img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
      

      $('#dragZone img').resizable({maxHeight: 600, aspectRatio: true, animate: true });
      

      这只会在dragZone div中获取img

      【讨论】:

      • 好吧,这很尴尬。我实际上确实尝试过,但它没有用..现在它可以了。谢谢!
      • 没问题,发生在我们最好的人身上!祝你好运!
      猜你喜欢
      • 2014-10-27
      • 1970-01-01
      • 1970-01-01
      • 2018-11-25
      • 1970-01-01
      • 2015-03-05
      • 1970-01-01
      • 1970-01-01
      • 2018-09-21
      相关资源
      最近更新 更多