Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

168
Vistas
JavaScript: "$" not a function errors

I inherited this code on a Shopify site. Moving it and some related code into a new theme based on Dawn. Don't think the theme is the issue at all but rather this code which is now triggering a "$" is not a function error. Here's an example of that code:

$('.section__choose-texture').on('click', '.content', function ( ){
  var current = $(this);

  $('.content').removeClass('active');
  current.addClass('active');

  $('#prodTextureItem').val(current.data('texture'));
  $('#productTexture').text(current.find('h3').text());
  $('.section__choose-coffee').show();

  var header_height = $('.site-header').height(),
      offset_top = $('.section__choose-coffee').offset().top,
      res = offset_top - header_height;

  $('html, body').animate({ scrollTop: res }, 'slow');
});

I added a "function stepOne() {" to the top and then closed it with a } followed by a call to the function but Shopify's editor says it is bad code. I think that's because function is listed on line one of my example.

So how can I make this function work properly? Does the code need to be completely rewritten? Or was I on the correct path on my idea?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

The $ function is not a JavaScript built-in.

It comes from the jQuery library.

Add this script tag before your script to import it:

<script src="https://code.jquery.com/jquery-3.6.0.min.js" integrity="sha256-/xUj+3OJU5yExlq6GSYGSHk7tPXikynS7ogEvDej/m4=" crossorigin="anonymous"></script>
about 4 years ago · Juan Pablo Isaza Denunciar

0

To use $ statement you have to add jquery files or reference to the project.

<script src="jquery.js"></script>

or from jquery.com

<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda