0

我试图模糊 DIV 中的每个图像,但无缘无故,它只是不起作用

<div id="textarea"  >random HTML with imgs</div>
                         <script type="text/javascript">
                            var arraysOfImgs = $('#textarea').find('img').map(function(){
                                return this.id;
                            }).get();
                            for (var i = 0; i < arraysOfImgs.length; i++){
                                Pixastic.process(arraysOfImgs[i], "blurfast", {
                                    amount : '1.5'
                                });
                            }

                        </script>';

即使这样也没有成功

<script type="text/javascript">
                         $(document).ready(function() {
                            var arraysOfImgs = $('#textarea').find(\'img\').map(function(){
                                return this.id;
                            }).get();

                            $.each(arraysOfImgs, function() {
                                Pixastic.process(this, "blurfast", {
                                    amount : '1.5'
                                });
                            });
                        }); 
                        </script>

没有显示错误,当我加载页面时没有任何反应......

编辑:没有更多的 php echo ..

4

2 回答 2

2

我认为的问题是您正在传递图像的 ID 值。Pixastic(如果是这个)需要图像元素。

您的代码可能如下所示:

$('#textarea img').each(function() {
    Pixastic.process(this, "blurfast", {
        amount : '1.5'
    });
});

另请注意,Pixastic 提供了一个 jQuery 插件,因此您可以这样做:

$('#textarea img').pixastic('blurfast', {amount: 1.5});
于 2011-09-25T16:17:01.067 回答
0

试试这个 :

      var img = new Image();
img.onload = function() {
    Pixastic.process(img, "blur");
}
document.body.appendChild(img);
img.src = "myimage.jpg";

并嵌入 blur.js ( http://www.pixastic.com/lib/git/pixastic/actions/blur.js )

于 2011-09-25T16:30:23.820 回答