Javascript 无法对div中的每个img应用函数

Javascript 无法对div中的每个img应用函数,javascript,jquery,pixastic,Javascript,Jquery,Pixastic,我试图模糊一个DIV中的每个图像,但没有理由,它就是不起作用 <div id="textarea" >random HTML with imgs</div> <script type="text/javascript"> var arraysOfImgs = $('#textarea').find('img').map(function(){

我试图模糊一个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>';
带有imgs的随机HTML
var arraysOfImgs=$('#textarea').find('img').map(函数(){
返回此.id;
}).get();
对于(var i=0;i
即使这样也不行

<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>

$(文档).ready(函数(){
var arraysOfImgs=$('#textarea').find(\'img\').map(function(){
返回此.id;
}).get();
$.each(arraysOfImgs,function(){
Pixastic.process(这是“模糊快速”{
金额:“1.5”
});
});
}); 
没有显示错误,当我加载页面时没有发生任何事情


编辑:不再使用php echo..

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

您的代码可能如下所示:

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

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

$('#textarea img').pixastic('blurfast', {amount: 1.5});
试试这个:

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

Embedded blur.js()

这看起来像PHP,把它放在一个HTML文件中,在Firefox中打开,用FireBug或Google ChromeGuy进行调试,这是js不应该的样子。首先,将它或PHP代码提取出来。其次,使用jqueryeach而不是for循环()。简单有效!,格雷西亚斯!