Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

281
Views
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 answers
Answer question

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 Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!