There is a tag <img src="/image123h100w100.jpg"> . How to use jquery to replace h100w100 with h200w200 after loading the page?

    1 answer 1

     <img src="/image123h100w100.jpg" class="needs-higher-resolution" /> $(document).ready(function(){ $(".needs-higher-resolution").attr("src", function(index, src){ $(this).removeClass("needs-higher-resolution"); // optional return src.replace("h100w100", "h200w200"); }); }); 

    From Grundy - Link to method documentation.

    • @Grundy - thank you - Igor
    • Worth adding to the answer :-) - Grundy
    • thank! in my case, $ (windows) .load (function () {your code}) helped; - Alexander Myravjev