Question : [ sign in id in jQuery

Hello,
I have a page where some elements have id build as t[32]

When I try to select it as
document.getElementById("t[32]")  it works

But if I do it jQuery-way
$("#t[32]")  it does not.

I guess it is due to [ sign. But how can I select such an element?

Answer : [ sign in id in jQuery

Use double slash : $("#t\\[32\\]")

test page :

1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<script language="javascript" src="http://code.jquery.com/jquery-1.4.2.min.js"></script>
<script language="javascript">
    $(document).ready(function() {
		alert( $("#t\\[32\\]").html() );
    });
</script>
</head>
<body>
<div id="t[32]">hello</div>
</body>
</html>
Random Solutions  
 
programming4us programming4us