skip to Main Content

I have a plugin that uses thickbox on the frontend. The HTML button for the thickbox modal is:

<a href="#TB_inline?width=640&height=600&inlineId=modal-window-id" class="thickbox">My Link
</a>

A user is using the Divi theme. It registers an event that gets triggered when the above link is clicked:

$('a[href*="#"]:not([href="#"])').click(function () {
    ....

    var target = $(this.hash);

    ....
});

The above line of code generates the following error:

Error: Syntax error, unrecognized expression #TB_inline?width=640&height=600&inlineId=modal-window-id jquery.js:2:12733

Can anyone see why this error is getting thrown?

2

Answers


  1. Simply because

    #TB_inline?width=640&height=600&inlineId=modal-window-id
    $('#TB_inline?width=640&height=600&inlineId=modal-window-id')
    

    Is not a valid jQuery selector.

    Login or Signup to reply.
  2. your selector is not valid. # is a special char and needs to be escaped like a[href*=\#]:not([href=\#])

    see https://api.jquery.com/category/selectors/

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search