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

283
Visualizações
jQuery wordpress TypeError: $ is not a function $ is not defined

I'm trying to use jquery to disable checkboxes after two options are selected on a restaurant menu. The options display in a modal. I've tried most if not all recommendations to resolve with no luck.

URL: https://206culinaryservices.com/place-an-order/

base jQuery code:

$(":checkbox[name='rms_mod_666[]']").change(function() {
  if ($(":checkbox[name='rms_mod_666[]']:checked").length == 2)
    $(":checkbox:not(:checked)").prop('disabled', true);
  else
    $(":checkbox:not(:checked)").prop('disabled', false);
});

seems to work fine in this jsfiddle: https://jsfiddle.net/R7Cwg/1/
but not in my use case.

I've tried wrapping in:

(function( $ ) {
  $(function() {
// insert above jquery code here
});
});

this resolves the error but the code still doesn't work as desired.

...

Another unsuccessful attempt:

(function($) { $(function(){
var maxCheckboxes = 2;

 $('input[name="rms_mod_666[]"]').change(function () {
     var checkedNum = $('input[name="rms_mod_666[]"]:checked').length;
     var allCheckoxesChecked = $('input[name="rms_mod_666[]"]:checked');
     var allCheckboxes = $("input[name='rms_mod_666[]']");

     //alert(checkedNum + " - " + maxCheckboxes);

     if (checkedNum == maxCheckboxes) {
         $(allCheckboxes).attr('disabled', 'disabled');
         $(allCheckoxesChecked).removeAttr('disabled');
//         alert("ooou equals and disable!");
     } else {
         $(allCheckboxes).removeAttr('disabled');
     }

 });
 });
 })(jQuery);

Any help is much appreciated.

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

0

Did you wrap like this ?

(function($){
    $(":checkbox[name='rms_mod_666[]']").change(function() {
        if ($(":checkbox[name='rms_mod_666[]']:checked").length == 2) {
        $(":checkbox:not(:checked)").prop('disabled', true);
        } else {
        $(":checkbox:not(:checked)").prop('disabled', false);
        }
    });
})(jQuery);

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