0

我有一个关于响应式设计和图像的问题。

这个 javascript 会导致浏览器同时加载“small.jpg”和“big.jpg”吗?

if (condition1) {
    //with jQuery im setting the source for the img tag
    $(this).attr('src',  'small.jpg');

} else if (condition2) {
    //with jQuery im setting the source for the img tag  
    $(this).attr('src',  'big.jpg');
}

亲切的问候

4

2 回答 2

0

这不会加载两个图像。如果满足第一个条件,则由于else if.

于 2013-10-11T12:41:10.293 回答
-1

取决于条件,但它应该可以解决问题。

于 2013-10-11T12:43:09.663 回答