Search code examples
jquerysizzle

Select a tag with a unicode char in its id


In HTML 5, unicode characters are allowed in a tag's id attribute. And the Sizzle library used by jQuery claims to have full unicode support.

My HTML file includes:

<p id='§'>Hello</p>

and doing this returns an empty array:

$('§')

Why doesn't this work?

(using jQuery 2.2.3)


Solution

  • You need to refer to the element by its CSS id syntax:

    $('#§')
    

    Adding the '#' before the identifier name should make it work.