Jules Martinez
Jules Martinez

Reputation: 692

Modifying src attr using replace

Hello i made a code where i get the last part of the src data and replace _t for empty space like this.

 // Get the current image number
        var current = $(next.index("img"));

        var nextUrl = next.attr("src").replace("_t", "");

This is the img example

<img src="http://farm1.static.flickr.com/28/66523124_b468cf4978_t.jpg" />

so in the example case i get this URL

http://farm1.static.flickr.com/28/66523124_b468cf4978

My question is ... I have to modify that code to actually change that at the beginin of the URL

in the Script im working now the thums are

<img id="extra_15" src="data/16/t_15_images.jpg" border="0" width="70px" class="">

And the big images are

<img id="extra_15" src="data/16/15_images.jpg" border="0" width="70px" class="">

how do i change that?

Upvotes: 0

Views: 109

Answers (1)

Adam Simpson
Adam Simpson

Reputation: 3681

Switch around the pattern you are looking for. Instead of _t do t_.

var nextUrl = next.attr("src").replace("t_", "");

Upvotes: 2

Related Questions