views:

407

answers:

1

Hello Guys,

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();
+2  A: 

EDIT: Your original code works fine. (jQuery 1.4.2)

You could write

$('*[id="0fb:Bactidol_Recorder.mp4"]')

However, it'll be slower.

The fastest way to do this would be to write

$(document.getElementById("0fb:Bactidol_Recorder.mp4"))
SLaks
this works perfectly. same thing i want to achieve.
steamboy
Then you should accept this answer by clicking the hollow check.
SLaks