jQuery :contains selector and unicode characters

I have an element like this (to save space in the menu since they can put up to 255 characters in it):

    <span class="tool_tip" title="The full title">The ful&#8230;</span>

While this seems to work:

    jQuery('span:contains(…)');

this does not:

    jQuery('span:contains(&#8230;)');

I am pretty sure that it would be bad to use the first one because if someone else saves the file, or the browser decides to get the file in a different character set for some reason things will not work.

There has to be a way to properly select this span, right? Turns out there is:

 
    jQuery('span:contains(\u2026)');

In other words:

Use the hex value instead of the decimal value as the selector and things will work out fine.


Related posts:

  1. JQuery and WordPress
  2. Ajaxy Pagination using jQuery
  3. A better way to use jQuery in WordPress Themes
  4. Using the jQuery-UI Autocomplete Widget
  5. A couple useful jQuery Snippets

Tags: , , , , , , ,