Change image link src

Asked

Viewed 46 times

-3

  • 2

    Code you’ve been making?

2 answers

1

I didn’t test, but considering 'image' being the link you passed, it probably works:

imagem = imagem.replace("150-150", "200-200");

1


Assuming there is no possibility of that expression 150-150 repeat in any part of the URL, it would be something like this:

$( document ).ready( fucntion() {

    $( 'ul#something li img' ).each( function() {

        var path = $( this ).attr( 'src' );

        $( this ).attr( 'src', path.replace( '150-150', '200-200' ) );

    });
});

Sets the seal, iterates and for each image found you get the path, steps to replace and redefine them.

  • Thank you very much Bruno

  • Good thing it worked, 'cause I didn’t even test it >.<

Browser other questions tagged

You are not signed in. Login or sign up in order to post.