Reputation: 1992
I work in Laravel and have a page http://localhost:8000/tours/
and jquery script on it. In the script, there is a code:
var i = 1;
$('<li>').append('<a href='load_page_"+i+"'>"+i+"</a>');
after code has worked, I have a link on the page:
<a href='tours/load_page_1'>1</a>
but I want it to be:
<a href='load_page_1'>1</a>
how can I achive that?
PS. My question is not how to modify href (.attr('href')), but how to make the link to be I want it to be when adding it as html via append/prepend/after/before etc (or explanation why it's impossible).
Upvotes: 1
Views: 892
Reputation: 5613
It sounds like what you're wanting is a link to http://localhost:8000/load_page_1
, but instead are getting a link to http://localhost:8000/tours/load_page_1
.
You should be able to get the link that you're wanting by changing your append line to $('<li>').append('<a href='../load_page_"+i+"'>"+i+"</a>');
The ../
part tells it to go one folder up in the directory tree and link to the specified page there.
Upvotes: 2