如果我使用以下功能。这是更新src和srcset属性的正确方法吗?
<img id="Image" srcset="img/my-large-image.jpg x2" src="img/my-image.jpg" width="500">
$("#Image").one("load", function() {
//code
}).attr("src", "img/my-new-image.jpg").attr("srcset", "img/my-new-large-image.jpg x2");
答案 0 :(得分:0)
是
$("#Image").one("load", function() {
//code
}).attr("src", "img/my-new-image.jpg").attr("srcset", "img/my-new-large-image.jpg x2");
&#13;
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<img id="Image" srcset="img/my-large-image.jpg x2" src="img/my-image.jpg" width="500">
&#13;