I am trying to select the option label (option with value "") from a select box through jQuery. I use the following selector:
$("[value='']");
This works in most browsers, however in IE7 it throws an exception. If I change it to the following (imho equivalent) selector, then it works fine:
$(":not(:not([value='']))");
I'd prefer not to use the latter, but can't think a of better equivalent of the prior.
Edit:
jQuery version: 1.3.1.
Exception:
Microsoft JScript runtime error: Exception thrown and not caught
on
if(S==null){throw"Syntax error, unrecognized expression: "+ab}
where
ab = "value='']"
Test setup:
To ensure nothing of my other code caused the problem I have reproduced the error in the following situation:
<html>
<head>
<script type="text/javascript" src="jquery-1.3.1.js"></script>
<script type="text/javascript">
$(document).ready(function(){
alert($("option[value='']").html());
});
</script>
</head>
<body>
<select>
<option value="">test</option>
<option value="1">test1</option>
<option value="2">test2</option>
</select>
</body>
</html>