1

I want to add string (WooCommerce product tag slug) to URL but I getting this error: Uncaught TypeError: $ is not a function

I get inspired by this JSFiddle

My JS code is:

<script>
     $checkboxes = $("input[type=checkbox");
     $checkboxes.change(function(){
       window.location.hash = "?product_tag=" + $checkboxes.filter(":checked").map(function(){
           return this.value;   
       }).get().join(",");
       console.log(window.location.hash);
     });
</script>
1

1 Answer 1

1

You need to add reference to jQuery in your code. Include it from a CDN (Content Delivery Network) and it will work.

<head>
   <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"> 
  </script>
</head>
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.