w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Using jQuery, relative paths within a div are updated to absolute paths but having trouble rewriting it to be more dynamic
var foo = {
    '/catalog.php':'http://www.mydomain.com',
    '/upgrade':'http://www.mydomain2.com'
};
$.each(foo,function (search,prefix) {
    $('#landing-page').find('a[href^="' + search +
'"]').each(function(element, index){
        $(this).attr('href',prefix + $(this).attr('href'));
    });
});

http://jsfiddle.net/U9RXL/1/





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.