Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

289
Visualizações
How can i select a a tag and after pressing button i can go to specified href link

The code of a href link that comes dynamically from database

@foreach($doctor->tuesday as $tuesday)
<a class="timing" id="{{$tuesday->id}}" onclick="clicktime({{$tuesday->id}})" href="{{url('/')}}/fixschedule/{{$tuesday->id}}">
<span>{{date("g:i a",strtotime($tuesday->starttime))}}</span>
</a>
@endforeach

after select class name will be change to timing selected for blue highlight,

i want to select an a element like this

when i will press the button then the i want to redirect the specified link of a href and i want to select only one element at a time

code of button

<div class="submit-section proceed-btn text-right">
<a href="#" onclick="submit()" class="btn btn-primary submit-btn">Proceed to Pay</a>
</div>

i used here code of jquery that only one element can change now i want to go only redirected link after submit pressed

<script>
    function clicktime(id)
    {
      $("a").removeClass("timing selected");
      $("a").toggleClass("timing");
      document.getElementById(id).className = "timing selected";
    }
</script>
about 4 years ago · Santiago Gelvez
1 Respostas
Responde à pergunta

0

First, prevent the a tag from redirecting with preventDefault();

@foreach($doctor->tuesday as $tuesday)
<a class="timing" id="{{$tuesday->id}}" onclick="preventDefault();clicktime({{$tuesday->id}})" 
href="{{url('/')}}/fixschedule/{{$tuesday->id}}">
<span>{{date("g:i a",strtotime($tuesday->starttime))}}</span>
</a>
@endforeach

then set the url on code of button like

<script>
function clicktime(id)
{
  $("a").removeClass("timing selected");
  $("a").toggleClass("timing");
  document.getElementById(id).className = "timing selected";
  $(".submit-btn").attr('href',$("#"+id).attr('href');
}
</script>
about 4 years ago · Santiago Gelvez Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda