Change url by JavaScript

// set new url

var str = jQuery( ‘#csv-dl-link’ ).attr( ‘href’ ); // getting the url
var res = str.split( “/” ); // spliting / exploding the url
var new_url = ”;

for ( var i = 0; i < res.length - 1; i++ ) { // concatenating new url new_url = new_url + res[ i ] + '/'; } new_url = new_url + 'anything you want to add here for you url'; jQuery( '#csv-dl-link' ).attr( 'href', new_url ); // replacing the url happy coding!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>