Search code examples
jquerymultilingualbase-url

remove part of jQuery base uri when changing src of an img tag


In a multilanguage website when changing the img.src attribute in jQuery, it looks for base url + src which becomes something like http://localhost/app/en/resources/images/img.jpg assuming base url is http://localhost/app/en/ and src is resources/images/img.jpg
In fact the img.jpg file is not under en folder so this should be omitted from the above location.
How can I do this?


Solution

  • You have two options:

    1. Give the absolute URL: http://www.google.com/...../image.png

    2. Give relative URL, two folders up: ../../image.png