1

I'm having problem selecting an element with an id like this <li ="0f:Bactidol_Recorder.mp4">.

I tried using the function that escapes meta-characters with two backslashes below from this jquery link but still can't select the element

Function:

function jq(myid) { 
   return '#' + myid.replace(/(:|\.)/g,'\\$1');
}

Example:

$(jq('0fb:Bactidol_Recorder.mp4')).empty()

Output:

$(#0fb\\:Bactidol_Recorder\\.mp4).empty();
MPelletier
  • 16,256
  • 15
  • 86
  • 137
steamboy
  • 1,162
  • 5
  • 20
  • 37
  • 1
    It's worth noting that this isn't a valid HTML `id` attribute. They must start with a letter. (See the HTML TR: http://www.w3.org/TR/REC-html40/types.html#type-name ) – porges Mar 22 '10 at 00:03
  • It works for me: http://jsbin.com/ajano3/edit – SLaks Mar 22 '10 at 00:10