This is done simply by doing this variable.
var base_url = '<?php echo base_url();?>'
This will have base url now. And now make a javascript function that will use this variable
function base_url(string){
return base_url + string;
}
And now this will always use the correct path.
var path = "assets/css/themes/" + color_ + ".css"
$('#style_color').attr("href", base_url(path) );