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

252
Visualizações
how to import external js file when using bootstrap?

I am very new to front-end dev and am trying to write an onClick() function for an element. However, the js file where the function lies seems not imported. I've followed some instructions to modify the orders, but unfortunately, it didn't solve my problem.

index.html

<head>
    <meta charset="utf-8">
    <link type="javascript" href="../js/jquery-1.11.0.js">
    <link type="javascript" href="../js/index.js">
    <link rel="stylesheet" href="../bootstrap-5.1.3-dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="../css/index.css">
    <title>Index</title>
</head>
<nav id="sideBarMenu" class="col-md-3 col-lg-2 d-md-block sidebar collapse">
    <div class="position-sticky pt-3">
        <h6 class="sidebar-heading d-flex justify-content-between align-items-center text-muted ps-2">
            <span> Personal Notification </span>
        </h6>
        <ul class="nav flex-column mb-2">
            <li class="nav-item">
            <a class="nav-link" href="#" onclick="showRsvs()">
                My Reservations
            </a>
            </li>
        </ul>
    </div>
</nav>

index.js

$(function(){
    // refresh time every seconds
    setInterval(function(){
        $("#clock").html(getTime());
    }, 1000);
})

function showRsvs(){
    $(this).addClass("active");
}

Both of the functions in this file are not functioning. And I can't see the js folder in Source panel of my broswer.

Console output

Uncaught ReferenceError: showRsvs is not defined

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

0

Remove the include js from the head, <link> tag is used to include css files, <script> tag is used for js files.

After </nav>, where nav ends insert these two lines

<script src="../js/jquery-1.11.0.js"></script>
<script src="../js/index.js"></script>

You are good to go

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