I have many database rows that used relative url with one directory up.
How do i change this relative url:
<a href="../somefolder"></a>
to
<a href="../additionalfolder/somefolder"></a>
FYI: I use jQuery 1.2.6
I have many database rows that used relative url with one directory up.
How do i change this relative url:
<a href="../somefolder"></a>
to
<a href="../additionalfolder/somefolder"></a>
FYI: I use jQuery 1.2.6
Try
$('a').attr('href', function(_, href){
return href.replace(/^\.\./, '../additionalfolder')
})
Hope this is the output you expect?
$(function(){
var $a =$('a');
var OldUrl = $a.attr('href');
var newUrl = OldUrl.replace("../","../additionalfolder/");
$a.attr('href', newUrl);
});
this might help you
var strUrl = window.location.protocol + "//" + window.location.host + "/";
this will give you the root folder path now you can concate your database path to this.