Laravel 5.5 link with Ancora

Asked

Viewed 213 times

0

I have the route below that redirects to the main page of my site..

Route::group(['prefix' =>'site', 'namespace' => 'site'], function(){
    Route::get('/', 'SiteController@index')->name('site');

I wanted to add an anchor to the div services on my site getting like this:

localhost:8000/site#servicos 

How do I do it in Laravel?

I’ve tried to:

 <a href='{{ route('site') }}#servicos'>Serviços</a>

 <a href='#servicos'>Serviços</a>

 <a href={{ route('site#servicos') }}'>Serviços</a>

 <a href={{ url('site#servicos') }}>'Serviços</a>

 <a href=/site#servicos>'Serviços</a>

all change the URL but do not redirect to the div I need, suggestions?

  • How so an anchor on the route? you want your page to speak one scroll to the other div? That’s it?

  • yes, an anchor on a link.... to go directly to the div that is in the middle of the index in the click...

  • 1

    Well, the first item should work. At least in my environment it worked. Are you sure that div has ID?

  • @Phiter thank you.. killed the problem... forgot the blessed ID!!!!! thank you

  • 1

    I was already with the answer ready, rs

  • beginner is fire rs... sometimes I give a flips kkkk

Show 1 more comment

1 answer

1


an anchor with # will follow an element that has the attribute ID with the same value, see:

<a href="#service">Serviços</a>


<div id="service"></div>
  • Thanks guys.. had forgotten the Bendido ID... kkkkk beginner is fire.. rs

Browser other questions tagged

You are not signed in. Login or sign up in order to post.