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

108
Visualizações
not redirecting to other page using jQuery

I'm quite new to jQuery and html, looked through google and these forums to no avail.

This is my HTML Code

<html>
<head>
    <link rel="stylesheet" href="reset.css" type="text/css">
    <link rel="stylesheet" href="index.css" type="text/css">
    <script src="./jquery.js" type="text/javascript"></script>
</head>
<body>
    <div id="container">
        <form id="form">
            <h1>Koks yra leistingas greitis miesto ribose?</h1>
            <input type="radio", id="ats1", name="atsakymas", value="1" ></input>
            <label for="ats1"> a</label>
            <br>
            <input type="radio", id="ats2", name="atsakymas", value="2" ></input>
            <label for="ats2"> b</label>
            <br>
            <input type="radio", id="ats3", name="atsakymas", value="3" ></input>
            <label for="ats3"> c</label>
            <br>
            <button id="Rinktis" type="submit">Rinktis</button>
            <button id="close">Išeiti</button>
        </form>
    </div>
    <script src="./index.js" type="text/javascript"></script>
</body>

And this is my jQuery line that I think should redirect me to another page

    $("#Rinktis").click(function (){
        document.location.href = "http://google.com";
        return;
    })

but it is doing nothing, am I doing something wrong?

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Your code (in JS) should be:

$("#Rinktis").click(function (e) {
    e.preventDefault();
    window.location.href = "http://www.google.com";
})

The return statement there is unnecesary. The e parameter in the click function represents the Event object. Since you're overriding the form's submit action (not sure why), you need that first line to stop the default action.

about 4 years ago · Juan Pablo Isaza 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