How can I replace URL address of an image source string only before the name of file?
Right now I am doing this like a hard coded way as $('img').attr('src', add+"slide1.jpg"); but I need to get rid of the name of file in the JS part and just update the URL string before the name of files
var add = "https://lamaisonduchien.ca/wp-content/uploads/revslider/home_1/";
$(".button").on("click", function(){
$('img').attr('src', add+"slide1.jpg");
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button class="button">Update</button><br />
<img src="http://www.dpwts.com/slide1.jpg" alt="Smiley face" height="300" width="300">
<img src="http://www.aseanta.org/images/slide/slide1.jpg" alt="Smiley face" height="300" width="300">