1

我的问题很基本,但我找不到。

我有一个相当大的图像库要显示在我的网站上,所以我编写了一个 jQuery 脚本来扫描文件夹,收集图像源并将它们作为背景图像放在正确的位置。这完美无缺。

我的第二步是在其上方添加一个图像副本并使用 Pixastic 库对其进行处理。我尝试使用如下所示的代码:

function blurBackground() {
$wrapper2.prepend('<img class="blur" src="'+$sourceImage+'" />'); // great, a copy of the image is set!
    $('.blur').load(function() {    // execute on load
        $('.blur').pixastic("blur").css('border','10px solid red'); // failed to process with pixastic, succeded to edit css
    });
}

如果我的<img src="something.jpg" class="blur" />标记中有一个存在,那么即使我剥离函数并仅使用该代码,一切都可以完美运行:

function blurBackground() {
 $('.blur').pixastic("blur");
}

问题是我无法处理任何预先或附加的图像。

我不知道我做错了什么。$sourceImage 是 100% 正确的,并且图像总是在函数执行之前被缓存。

4

1 回答 1

0

It looks to me like you need to do this specify this image with the class .blur within the .load event handler.

$('.blur').load(function() {   
    $(this).pixastic("blur").css('border','10px solid red');
});
于 2011-08-26T08:54:46.990 回答