jQuery update causes unrecognized expression error

jQuery update causes unrecognized expression error

I am trying to update my jQuery version from 1.10.2 to 3.6.0. When I use the 3.6.0 version, I get the following error - "Uncaught Error: Syntax error, unrecognized expression: a[href$=]" Even when location.hash has a value, it gives the same error. For example, page.html#ceftin will give the error with a[href$=ceftin] listed in the error. This does not occur with version 1.10.2.


Here is the script where the error occurs:


 
  1. $(document).ready(function(){
  2. var anchor_hash = location.hash;
  3. var anchor_link = $("a[href$=" + anchor_hash + "]").closest(".gb-div");
  4. var expand_image = $("a[href$=" + anchor_hash + "]").closest(".gb-div").prevAll("li:first");
  5. var close_icon = '<img src="image/gb-close-icon.svg" class="image-expand">';
  6. var anchor_list = $("a[href$=" + anchor_hash + "]").parent();
  7. var original_color = $(anchor_list).css('background-color');
  8. var time = 3500; anchor_link.slideDown(
  9. anchor_link.slideDown(0); expand_image.children(
  10. expand_image.children('.gb-expand').children(".gb-expand-icon").html(close_icon);
All of my other jQuery script works fine with version 3.6.0. Any help would be appreciated.