小编joh*_*ohn的帖子

Jcrop中的多张图片和prewiev.如何将许多id传递给javascript函数

我在我的应用程序中使用Jcrop插件(Jquery).我决定使用一些ajax解决方案但是将值传递给函数有问题.我不知道是否缺乏JavaScript技能或Jcrop问题.这是代码

jQuery(window).load(function(){

            jQuery('#cropbox').Jcrop({
                onChange: showPreview,
                onSelect: showPreview,
                aspectRatio: 1
            });

        });

        // Our simple event handler, called from onChange and onSelect
        // event handlers, as per the Jcrop invocation above
        function showPreview(coords)
        {
            if (parseInt(coords.w) > 0)
            {
                var rx = 100 / coords.w;
                var ry = 100 / coords.h;

                jQuery('#preview').css({
                    width: Math.round(rx * 500) + 'px',
                    height: Math.round(ry * 370) + 'px',
                    marginLeft: '-' + Math.round(rx * coords.x) + 'px',
                    marginTop: '-' + Math.round(ry * coords.y) + 'px'
                }); …
Run Code Online (Sandbox Code Playgroud)

jquery javascript-events jcrop

3
推荐指数
1
解决办法
5631
查看次数

标签 统计

javascript-events ×1

jcrop ×1

jquery ×1