Selector with escaped character doesn't work when used with a context
I am having trouble writing a selector to filter selects by name when using a context and the name has escaped "[" and "]" characters. This is easily reproduced with the following code (uses console.log from FireBug):
- <html>
<head>
<script src="jquery-1.4.2.min.js" type="text/javascript"></script>
<script>
$(function()
{
var ctx = $("#mydiv");
// outputs "1: test[0]"
$("select[name^=test]", ctx).each(function() { console.log("1: " + $(this).attr("name")) });
// no output
$("select[name^=test\\[]", ctx).each(function() { console.log("2: " + $(this).attr("name")) });
// outputs "3: test[0]"
$("select[name^=test\\[]").each(function() { console.log("3: " + $(this).attr("name")) });
});
</script>
<body>
<div id="mydiv">
<select name="test[0]">
</div>
</body>
</html>
Can anyone confirm if this is a bug with jquery ?
Thanks,
Slaren